예제 #1
0
        public static bool Register(UserProfile userInfo, out string errorMsg)
        {
            errorMsg = "";
            UserProfile regInfo = new UserProfile()
            {
                UserName = userInfo.UserName,
                Password = SecurityHelper.Encrypt(userInfo.Password),
                RoleId=1//权限角色
            };
            int registerState;
            UserProfileData userPorfile=new UserProfileData();
            var userList=userPorfile.select(0," username ","username='******'",null);
            bool  isNewName = true ;
            if (userList.Count > 0)
            {
                isNewName = false;
                errorMsg = "该用户名已注册";
                return isNewName;

            }
            try
            {
                registerState = userPorfile.insert(regInfo);
                if (registerState > 0)
                {
                    return true;
                }
                else return false;
            }
            catch (Exception ex)
            {
                errorMsg = "注册出错" + ex.ToString();
                return false;
            }
        }
 public virtual void AddTemporaryUserProfile(UserProfileData userProfile)
 {
     //m_log.DebugFormat("[TEMP USER PROFILE]: Adding {0} {1}", userProfile.Name, userProfile.ID);
     
     lock (m_profiles)
     {
         m_profiles[userProfile.ID] = userProfile;
     }
 }
예제 #3
0
        public void SetUpLoginEnviroment()
        {
            m_capsEndPoint = new IPEndPoint(IPAddress.Loopback, 9123);
            m_commsManager = new TestCommunicationsManager(new NetworkServersInfo(42, 43));
            m_regionConnector = new TestLoginToRegionConnector();

            m_regionConnector.AddRegion(new RegionInfo(42, 43, m_capsEndPoint, m_regionExternalName));

            m_localUserServices = (LocalUserServices) m_commsManager.UserService;
            m_localUserServices.AddUser(m_firstName,m_lastName,"boingboing","*****@*****.**",42,43);

            m_loginService = new LLStandaloneLoginService((UserManagerBase) m_localUserServices, "Hello folks", new TestInventoryService(),
                  m_commsManager.NetworkServersInfo, true, new LibraryRootFolder(String.Empty), m_regionConnector);

            m_userProfileData = m_localUserServices.GetUserProfile(m_firstName, m_lastName);
        }
예제 #4
0
        /// <summary>
        /// Not really informing the region. Just filling out the response fields related to the region.
        /// </summary>
        /// <param name="sim"></param>
        /// <param name="user"></param>
        /// <param name="response"></param>
        /// <returns>true if the region was successfully contacted, false otherwise</returns>
        protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response, IPEndPoint remoteClient)
        {
            IPEndPoint endPoint = regionInfo.ExternalEndPoint;

            response.SimAddress  = endPoint.Address.ToString();
            response.SimPort     = (uint)endPoint.Port;
            response.RegionX     = regionInfo.RegionLocX;
            response.RegionY     = regionInfo.RegionLocY;
            response.SimHttpPort = regionInfo.HttpPort;

            string capsPath     = CapsUtil.GetRandomCapsObjectPath();
            string capsSeedPath = CapsUtil.GetCapsSeedPath(capsPath);

            // Don't use the following!  It Fails for logging into any region not on the same port as the http server!
            // Kept here so it doesn't happen again!
            // response.SeedCapability = regionInfo.ServerURI + capsSeedPath;

            string seedcap = "http://";

            if (m_serversInfo.HttpUsesSSL)
            {
                // For NAT
                string host = NetworkUtil.GetHostFor(remoteClient.Address, m_serversInfo.HttpSSLCN);

                seedcap = "https://" + host + ":" + m_serversInfo.httpSSLPort + capsSeedPath;
            }
            else
            {
                // For NAT
                string host = NetworkUtil.GetHostFor(remoteClient.Address, regionInfo.ExternalHostName);

                seedcap = "http://" + host + ":" + m_serversInfo.HttpListenerPort + capsSeedPath;
            }

            response.SeedCapability = seedcap;

            // Notify the target of an incoming user
            m_log.InfoFormat(
                "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection",
                regionInfo.RegionName, response.RegionX, response.RegionY, regionInfo.ServerURI);

            // Update agent with target sim
            user.CurrentAgent.Region = regionInfo.RegionID;
            user.CurrentAgent.Handle = regionInfo.RegionHandle;

            return(true);
        }
예제 #5
0
 public void UpdateEmail(UserProfileData userProfileData)
 {
     try
     {
         using (uow = new VendorAPIRepository())
         {
             User user = uow.UserRepository.Get().Where(x => x.UserID == userProfileData.UserId).FirstOrDefault();
             if (user != null)
             {
                 user.Email = userProfileData.Email;
                 uow.UserRepository.Update(user);
                 uow.Save();
             }
         }
     }
     catch (Exception ex) { }
 }
예제 #6
0
        public ActionResult Index(SearchUser userSearch)
        {
            using (InStepContext db = new InStepContext())
            {
                IQueryable <UserProfileData> users = from t1 in db.UserData
                                                     join t2 in db.UserProfiles on t1.Id equals t2.UserId into t21
                                                     from t22 in t21.DefaultIfEmpty()
                                                     select new UserProfileData {
                    Address    = t22.Address,
                    BirthDate  = t1.BirthDate,
                    CityId     = t22 == null ? (int?)null : t22.CityId,
                    CountryId  = t22 == null ? (int?)null : t22.CountryId,
                    FirstName  = t1.FirstName,
                    SecondName = t1.SecondName,
                    LastName   = t1.LastName,
                    Sex        = t1.Sex
                };

                if (userSearch.SearchString != null)
                {
                    users = users.Where(r => r.LastName.Contains(userSearch.SearchString));
                }
                if (userSearch.SearchAddres != null)
                {
                    users = users.Where(r => r.Address.Contains(userSearch.SearchAddres));
                }

                List <UserProfileData> data = new List <UserProfileData>();
                foreach (var item in users.ToList())
                {
                    UserProfileData u = new UserProfileData();
                    u.FirstName  = item.FirstName;
                    u.SecondName = item.SecondName;
                    u.LastName   = item.LastName;
                    u.Sex        = item.Sex;
                    u.BirthDate  = item.BirthDate;
                    u.CityId     = item.CityId;
                    u.CountryId  = item.CountryId;
                    u.Address    = item.Address;
                    data.Add(u);
                }
                userSearch.Users = data;
            }

            return(View(userSearch));
        }
        public void ProfileUserIDAndRoleTypeDisable(UserProfileData input)
        {
            //Navigate to usr profile from PersonalMgtMenu.
            PersonalMgt.NavigatorToUserProfile();
            TimeManager.LongPause();
            TimeManager.LongPause();

            PersonalMgt.ClickViewUserProfile();
            TimeManager.LongPause();
            TimeManager.LongPause();

            //Modify the profile
            UserProfile.ClickModifyButton();
            TimeManager.LongPause();
            Assert.IsFalse(UserProfile.IsRoleTypeComboboxEnable());
            Assert.IsFalse(UserProfile.IsNameTextFieldEnable());
        }
예제 #8
0
        /// <summary>
        /// This generates authorization keys in the form
        /// http://userserver/uuid
        /// after verifying that the caller is, indeed, authorized to request a key
        /// </summary>
        /// <param name="url">URL of the user server</param>
        /// <param name="userID">The user ID requesting the new key</param>
        /// <param name="authToken">The original authorization token for that user, obtained during login</param>
        /// <returns></returns>
        public string GetNewKey(string url, UUID userID, UUID authToken)
        {
            UserProfileData profile = GetUserProfile(userID);
            string          newKey  = string.Empty;

            if (!url.EndsWith("/"))
            {
                url = url + "/";
            }

            if (profile != null)
            {
                // I'm overloading webloginkey for this, so that no changes are needed in the DB
                // The uses of webloginkey are fairly mutually exclusive
                if (profile.WebLoginKey.Equals(authToken))
                {
                    newKey = UUID.Random().ToString();
                    List <string> keys;
                    lock (m_userKeys)
                    {
                        if (m_userKeys.ContainsKey(userID))
                        {
                            keys = m_userKeys[userID];
                        }
                        else
                        {
                            keys = new List <string>();
                            m_userKeys.Add(userID, keys);
                        }
                        keys.Add(newKey);
                    }
                    m_log.InfoFormat("[USERAUTH]: Successfully generated new auth key for user {0}", userID);
                }
                else
                {
                    m_log.Warn("[USERAUTH]: Unauthorized key generation request. Denying new key.");
                }
            }
            else
            {
                m_log.Warn("[USERAUTH]: User not found.");
            }

            return(url + newKey);
        }
예제 #9
0
        /// <summary>
        /// Parse a URL with a relative path of the form /users/First_Last and try to
        /// retrieve the profile matching that avatar name
        /// </summary>
        /// <param name="requestUrl">URL to parse for an avatar name</param>
        /// <param name="profile">Profile data for the avatar</param>
        /// <returns>True if the parse and lookup were successful, otherwise false</returns>
        bool TryGetProfile(Uri requestUrl, out UserProfileData profile)
        {
            if (requestUrl.Segments.Length == 3 && requestUrl.Segments[1] == "users/")
            {
                // Parse the avatar name from the path
                string   username = requestUrl.Segments[requestUrl.Segments.Length - 1];
                string[] name     = username.Split('_');

                if (name.Length == 2)
                {
                    profile = m_loginService.GetTheUser(name[0], name[1]);
                    return(profile != null);
                }
            }

            profile = null;
            return(false);
        }
예제 #10
0
        public void T012_TestAuthenticatedLoginForBuddies()
        {
            TestHelper.InMethod();
            // 1.1) Test for budddies!
            m_localUserServices.AddUser("Friend", "Number1", "boingboing", "*****@*****.**", 42, 43);
            m_localUserServices.AddUser("Friend", "Number2", "boingboing", "*****@*****.**", 42, 43);

            UserProfileData friend1 = m_localUserServices.GetUserProfile("Friend", "Number1");
            UserProfileData friend2 = m_localUserServices.GetUserProfile("Friend", "Number2");

            m_localUserServices.AddNewUserFriend(friend1.ID, m_userProfileData.ID, 1);
            m_localUserServices.AddNewUserFriend(friend1.ID, friend2.ID, 2);

            Hashtable loginParams = new Hashtable();

            loginParams["first"]  = "Friend";
            loginParams["last"]   = "Number1";
            loginParams["passwd"] = "boingboing";

            ArrayList sendParams = new ArrayList();

            sendParams.Add(loginParams);
            sendParams.Add(m_capsEndPoint);                    // is this parameter correct?
            sendParams.Add(new Uri("http://localhost:8002/")); // is this parameter correct?

            XmlRpcRequest request = new XmlRpcRequest("login_to_simulator", sendParams);

            IPAddress      tmpLocal = Util.GetLocalHost();
            IPEndPoint     tmpEnd   = new IPEndPoint(tmpLocal, 80);
            XmlRpcResponse response = m_loginService.XmlRpcLoginMethod(request, tmpEnd);

            Hashtable responseData = (Hashtable)response.Value;

            ArrayList friendslist = (ArrayList)responseData["buddy-list"];

            Assert.That(friendslist, Is.Not.Null);

            Hashtable buddy1 = (Hashtable)friendslist[0];
            Hashtable buddy2 = (Hashtable)friendslist[1];

            Assert.That(friendslist.Count, Is.EqualTo(2));
            Assert.That(m_userProfileData.ID.ToString(), Is.EqualTo(buddy1["buddy_id"]) | Is.EqualTo(buddy2["buddy_id"]));
            Assert.That(friend2.ID.ToString(), Is.EqualTo(buddy1["buddy_id"]) | Is.EqualTo(buddy2["buddy_id"]));
        }
예제 #11
0
        override public void AddNewUserProfile(UserProfileData profile)
        {
            if (profile.ID == UUID.Zero)
            {
                m_log.ErrorFormat("[NHIBERNATE] Attempted to add User {0} {1} with zero UUID, throwintg exception as this is programming error ", profile.FirstName, profile.SurName);
                return;
            }

            if (!ExistsUser(profile.ID))
            {
                m_log.InfoFormat("[NHIBERNATE] AddNewUserProfile {0}", profile.ID);
                manager.Insert(profile);
            }
            else
            {
                m_log.ErrorFormat("[NHIBERNATE] Attempted to add User {0} {1} that already exists, updating instead", profile.FirstName, profile.SurName);
                UpdateUserProfile(profile);
            }
        }
예제 #12
0
        /// <summary>
        /// Reset a user password.
        /// </summary>
        /// <param name="firstName"></param>
        /// <param name="lastName"></param>
        /// <param name="newPassword"></param>
        /// <returns>true if the update was successful, false otherwise</returns>
        public virtual bool ResetUserPassword(string firstName, string lastName, string newPassword)
        {
            string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(newPassword) + ":" + String.Empty);

            UserProfileData profile = GetUserProfile(firstName, lastName);

            if (null == profile)
            {
                m_log.ErrorFormat("[USERSTORAGE]: Could not find user {0} {1}", firstName, lastName);
                return(false);
            }

            profile.PasswordHash = md5PasswdHash;
            profile.PasswordSalt = String.Empty;

            UpdateUserProfile(profile);

            return(true);
        }
예제 #13
0
        /// <summary>
        /// Converts a user profile to an XML element which can be returned
        /// </summary>
        /// <param name="profile">The user profile</param>
        /// <returns>A string containing an XML Document of the user profile</returns>
        public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile)
        {
            XmlRpcResponse response     = new XmlRpcResponse();
            Hashtable      responseData = new Hashtable();

            // Account information
            responseData["firstname"] = profile.FirstName;
            responseData["lastname"]  = profile.SurName;
            responseData["uuid"]      = profile.ID.ToString();
            // Server Information
            responseData["server_inventory"] = profile.UserInventoryURI;
            responseData["server_asset"]     = profile.UserAssetURI;
            // Profile Information
            responseData["profile_about"]           = CleanInvalidXmlChars(profile.AboutText);
            responseData["profile_firstlife_about"] = CleanInvalidXmlChars(profile.FirstLifeAboutText);
            responseData["profile_webloginkey"]     = profile.WebLoginKey;
            responseData["profile_firstlife_image"] = profile.FirstLifeImage.ToString();
            responseData["profile_image"]           = profile.Image.ToString();
            responseData["profile_created"]         = profile.Created.ToString();
            responseData["profile_lastlogin"]       = profile.LastLogin.ToString();
            // Home region information
            responseData["home_coordinates_x"] = profile.HomeLocation.X.ToString();
            responseData["home_coordinates_y"] = profile.HomeLocation.Y.ToString();
            responseData["home_coordinates_z"] = profile.HomeLocation.Z.ToString();

            responseData["home_region"]    = profile.HomeRegion.ToString();
            responseData["home_region_id"] = profile.HomeRegionID.ToString();

            responseData["home_look_x"] = profile.HomeLookAt.X.ToString();
            responseData["home_look_y"] = profile.HomeLookAt.Y.ToString();
            responseData["home_look_z"] = profile.HomeLookAt.Z.ToString();

            responseData["user_flags"]  = profile.UserFlags.ToString();
            responseData["god_level"]   = profile.GodLevel.ToString();
            responseData["custom_type"] = profile.CustomType;
            responseData["partner"]     = profile.Partner.ToString();
            responseData["profileURL"]  = profile.ProfileURL;


            response.Value = responseData;

            return(response);
        }
        public void ViewProfile(UserProfileData input)
        {
            //Navigate to usr profile from PersonalMgtMenu.
            PersonalMgt.NavigatorToUserProfile();
            TimeManager.MediumPause();

            PersonalMgt.ClickViewUserProfile();
            TimeManager.LongPause();
            TimeManager.LongPause();

            //View user profile
            Assert.AreEqual(input.ExpectedData.Name, UserProfile.GetNameValue());
            Assert.AreEqual(input.ExpectedData.RealName, UserProfile.GetRealNameValue());
            Assert.AreEqual(input.ExpectedData.Type, UserProfile.GetTypeValue());
            Assert.AreEqual(input.ExpectedData.Title, UserProfile.GetTitleValue());
            Assert.AreEqual(input.ExpectedData.Email, UserProfile.GetEmailValue());
            Assert.AreEqual(input.ExpectedData.Telephone, UserProfile.GetTelephoneValue());
            Assert.AreEqual(input.ExpectedData.Comments, UserProfile.GetCommentValue());
        }
        public async Task <IActionResult> Put([FromBody] UserProfileData user)
        {
            var response = await _userProfileService.SaveUserProfileAsync(user, _userContext.UserName);

            if (response.IsSuccess)
            {
                return(Success(response.UserProfile));
            }
            else
            {
                var problemDetails = new ValidationProblemDetails(response.ModelState)
                {
                    Title    = "Error updating User Profile",
                    Detail   = "One or more errors occurred when updating the User Profile.  See form for error details",
                    Status   = (int)HttpStatusCode.BadRequest,
                    Instance = $"urn:kbxl:error:{Guid.NewGuid()}"
                };
                return(BadRequest(problemDetails));
            }
        }
예제 #16
0
        public XmlRpcResponse XmlRPCAtRegion(XmlRpcRequest request, IPEndPoint remoteClient)
        {
            // Check IP Endpoint Access
            if (!TrustManager.Instance.IsTrustedPeer(remoteClient))
            {
                return(Util.CreateTrustManagerAccessDeniedResponse());
            }

            XmlRpcResponse response     = new XmlRpcResponse();
            Hashtable      requestData  = (Hashtable)request.Params[0];
            Hashtable      responseData = new Hashtable();
            string         returnstring = "FALSE";

            if (requestData.Contains("avatar_id") && requestData.Contains("region_handle") &&
                requestData.Contains("region_uuid"))
            {
                // ulong cregionhandle = 0;
                UUID regionUUID;
                UUID avatarUUID;

                UUID.TryParse((string)requestData["avatar_id"], out avatarUUID);
                UUID.TryParse((string)requestData["region_uuid"], out regionUUID);

                if (avatarUUID != UUID.Zero)
                {
                    // Force a refresh for this due to Commit below.
                    UserProfileData userProfile = m_userDataBaseService.GetUserProfile(avatarUUID, true);
                    userProfile.CurrentAgent.Region = regionUUID;
                    userProfile.CurrentAgent.Handle = (ulong)Convert.ToInt64((string)requestData["region_handle"]);
                    //userProfile.CurrentAgent.
                    m_userDataBaseService.CommitAgent(ref userProfile);
                    //setUserProfile(userProfile);


                    returnstring = "TRUE";
                }
            }
            responseData.Add("returnString", returnstring);
            response.Value = responseData;
            return(response);
        }
예제 #17
0
        public async Task <UserProfileData> GetUserByUserName(string userName)
        {
            //TODO USE AUTOMAPPER!
            UserProfileData userInfo = await uManager.Users.Where(x => x.UserName.ToLower() == userName.ToLower())
                                       .Select(x => new UserProfileData
            {
                Id               = x.Id,
                UserName         = x.UserName,
                Gender           = x.Gender.ToString(),
                CookRank         = x.CookRank.ToString(),
                FirstName        = x.FirstName,
                LastName         = x.LastName,
                AvPic            = x.AvatarPicture,
                Email            = x.Email,
                Description      = x.Description,
                RecipesShared    = x.SharedRecipes.Count(),
                BlockedUserNames = x.UsersIBlocked.Where(x => !x.IsDeleted).Select(x => x.Irritator.UserName).ToArray()
            }).FirstOrDefaultAsync();

            return(userInfo);
        }
        public void GetProfile_returns_chase_and_makenna()
        {
            var actual = new UserProfileService().GetProfile();

            var expectedChase   = UserProfileData.ChaseProfile();
            var expectedMakenna = UserProfileData.MakennaProfile();
            var actualChase     = actual.First(x => x.Id == expectedChase.Id);
            var actualMakenna   = actual.First(x => x.Id == expectedMakenna.Id);

            Assert.AreEqual(2, actual.Count());

            Assert.AreEqual(expectedChase.Id, actualChase.Id);
            Assert.AreEqual(expectedChase.FirstName, actualChase.FirstName);
            Assert.AreEqual(expectedChase.LastName, actualChase.LastName);
            Assert.AreEqual(expectedChase.AccessToken, actualChase.AccessToken);

            Assert.AreEqual(expectedMakenna.Id, actualMakenna.Id);
            Assert.AreEqual(expectedMakenna.FirstName, actualMakenna.FirstName);
            Assert.AreEqual(expectedMakenna.LastName, actualMakenna.LastName);
            Assert.AreEqual(expectedMakenna.AccessToken, actualMakenna.AccessToken);
        }
예제 #19
0
        override public void AddNewUserProfile(UserProfileData profile)
        {
            if (profile.ID == UUID.Zero)
            {
                m_log.ErrorFormat("[NHIBERNATE] Attempted to add User {0} {1} with zero UUID, throwintg exception as this is programming error ", profile.FirstName, profile.SurName);
                return;
            }

            if (!ExistsUser(profile.ID))
            {
                m_log.InfoFormat("[NHIBERNATE] AddNewUserProfile {0}", profile.ID);
                manager.Insert(profile);
                // Agent should not be saved according to BasicUserTest.T015_UserPersistency()
                // SetAgentData(profile.ID, profile.CurrentAgent);
            }
            else
            {
                m_log.ErrorFormat("[NHIBERNATE] Attempted to add User {0} {1} that already exists, updating instead", profile.FirstName, profile.SurName);
                UpdateUserProfile(profile);
            }
        }
        public override UserProfileData GetTheUser(string firstname, string lastname)
        {
            UserProfileData profile = m_userManager.GetUserProfile(firstname, lastname);

            if (profile != null)
            {
                return(profile);
            }

            if (!m_authUsers)
            {
                //no current user account so make one
                m_log.Info("[LOGIN]: No user account found so creating a new one.");

                m_userManager.AddUser(firstname, lastname, "test", String.Empty, m_defaultHomeX, m_defaultHomeY);

                return(m_userManager.GetUserProfile(firstname, lastname));
            }

            return(null);
        }
예제 #21
0
        public virtual bool UpdateUserProfile(UserProfileData data)
        {
            bool result = false;

            foreach (IUserDataPlugin plugin in m_plugins)
            {
                try
                {
                    plugin.UpdateUserProfile(data);
                    result = true;
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat(
                        "[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}",
                        data.FirstName, data.SurName, plugin.Name, e.ToString());
                }
            }

            return(result);
        }
예제 #22
0
        /// <summary>
        /// Process a user logoff from OpenSim.
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="regionid"></param>
        /// <param name="regionhandle"></param>
        /// <param name="position"></param>
        /// <param name="lookat"></param>
        public virtual void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
        {
            if (StatsManager.UserStats != null)
            {
                StatsManager.UserStats.AddLogout();
            }

            UserProfileData userProfile = GetUserProfile(userid);

            if (userProfile != null)
            {
                UserAgentData userAgent = userProfile.CurrentAgent;
                if (userAgent != null)
                {
                    userAgent.AgentOnline = false;
                    userAgent.LogoutTime  = Util.UnixTimeSinceEpoch();
                    //userAgent.sessionID = UUID.Zero;
                    if (regionid != UUID.Zero)
                    {
                        userAgent.Region = regionid;
                    }
                    userAgent.Handle   = regionhandle;
                    userAgent.Position = position;
                    userAgent.LookAt   = lookat;
                    //userProfile.CurrentAgent = userAgent;
                    userProfile.LastLogin = userAgent.LogoutTime;

                    CommitAgent(ref userProfile);
                }
                else
                {
                    // If currentagent is null, we can't reference it here or the UserServer crashes!
                    m_log.Info("[LOGOUT]: didn't save logout position: " + userid.ToString());
                }
            }
            else
            {
                m_log.Warn("[LOGOUT]: Unknown User logged out");
            }
        }
예제 #23
0
        public Dictionary <UUID, SceneOwnerCounts> GetCurrentSceneOwnerCounts()
        {
            Dictionary <UUID, SceneOwnerCounts> SOGTable = new Dictionary <UUID, SceneOwnerCounts>();

            foreach (Scene scene in m_localScenes)
            {
                List <EntityBase> EntityList = scene.GetEntities();
                foreach (EntityBase ent in EntityList)
                {
                    if (ent is SceneObjectGroup)
                    {
                        SceneObjectGroup SOG = (SceneObjectGroup)ent;
                        if (SOGTable.ContainsKey(SOG.OwnerID))
                        {
                            SceneOwnerCounts counts = SOGTable[SOG.OwnerID];
                            counts.TotalObjects++;
                            counts.TotalPrims    += SOG.LandImpact;
                            SOGTable[SOG.OwnerID] = counts;
                        }
                        else
                        {
                            SceneOwnerCounts counts  = new SceneOwnerCounts();
                            UserProfileData  profile = scene.CommsManager.UserService.GetUserProfile(SOG.OwnerID);
                            if (profile == null)
                            {
                                counts.OwnerName = "(Group-deeded, or unknown user)";
                            }
                            else
                            {
                                counts.OwnerName = profile.Name;
                            }
                            counts.TotalObjects   = 1;
                            counts.TotalPrims     = SOG.LandImpact;
                            SOGTable[SOG.OwnerID] = counts;
                        }
                    }
                }
            }
            return(SOGTable);
        }
예제 #24
0
        /// <summary>
        /// Updates a user profile stored in the DB
        /// </summary>
        /// <param name="user">The profile data to use to update the DB</param>
        public override bool UpdateUserProfile(UserProfileData user)
        {
            MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile");

            try
            {
                dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
                                          user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y,
                                          user.HomeLocation.Z, user.HomeLookAt.X,
                                          user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin,
                                          user.UserInventoryURI,
                                          user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText,
                                          user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey,
                                          user.UserFlags, user.GodLevel, user.CustomType, user.Partner);
            }
            finally
            {
                dbm.Release();
            }

            return(true);
        }
        public void UpdateAvatarProperties(IClientAPI remoteClient, UserProfileData newProfile)
        {
            UserProfileData Profile = m_scene.CommsManager.UserService.GetUserProfile(newProfile.ID);

            // if it's the profile of the user requesting the update, then we change only a few things.
            if (remoteClient.AgentId.CompareTo(Profile.ID) == 0)
            {
                Profile.Image              = newProfile.Image;
                Profile.FirstLifeImage     = newProfile.FirstLifeImage;
                Profile.AboutText          = newProfile.AboutText;
                Profile.FirstLifeAboutText = newProfile.FirstLifeAboutText;
            }
            else
            {
                return;
            }

            if (m_scene.CommsManager.UserService.UpdateUserProfile(Profile))
            {
                RequestAvatarProperty(remoteClient, newProfile.ID);
            }
        }
예제 #26
0
        private void SetSecurityProperties(UserEntity user, UserProfileData userProfile)
        {
            //Find the scac incase it was not loaded as part of the User Entity
            var primaryScac = _context.CarrierScacs.Find(user.PrimaryScac);

            if (primaryScac != null)
            {
                userProfile.AvailableCarrierScacs = GetAuthorizedScas();
                userProfile.AuthorizedShippersForMyPrimaryScac = _securityService.GetAuthorizedCustomersByScac().ToList();
            }

            if (user.PrimaryCustomerId.HasValue)
            {
                userProfile.MyCustomerContractedScacs = _securityService
                                                        .GetCustomerContractedScacsByPrimaryCustomer()
                                                        .Select(carrierScac => carrierScac.Scac)
                                                        .ToList();
            }

            userProfile.SecurityAccessRoles = _securityService.GetUserRoles().ToList();
            userProfile.IsShipper           = SecurityRoles.ShipperRoles.Any(role => userProfile.SecurityAccessRoles.Any(securityAccessRole => securityAccessRole.AccessRoleName == role)) && user.PrimaryCustomerId != null;
            userProfile.IsCarrier           = SecurityRoles.CarrierRoles.Any(role => userProfile.SecurityAccessRoles.Any(securityAccessRole => securityAccessRole.AccessRoleName == role)) && user.PrimaryScac != null;
            userProfile.IsAdmin             = SecurityRoles.AdminRoles.Any(role => userProfile.SecurityAccessRoles.Any(securityAccessRole => securityAccessRole.AccessRoleName == role));

            var defaultCommodityRoles = new List <string> {
                SecurityRoles.ShipperAdmin, SecurityRoles.ShipperUser, SecurityRoles.ShipperUserViewOnly
            };

            userProfile.CanSetDefaultCommodity = defaultCommodityRoles.Any(role => userProfile.SecurityAccessRoles.Any(securityAccessRole => securityAccessRole.AccessRoleName == role));

            if (userProfile.IsShipper)
            {
                userProfile.FocusEntity = _mapper.Map <UserFocusEntityData>(user.PrimaryCustomer);
            }
            else if (userProfile.IsCarrier)
            {
                userProfile.FocusEntity = _mapper.Map <UserFocusEntityData>(user.PrimaryScacEntity);
            }
        }
예제 #27
0
        public UserProfileData GetUserProfileData(int userId)
        {
            UserProfileData userProfileData = new UserProfileData();

            using (uow = new VendorAPIRepository())
            {
                UserEntity userEntity = GetProfileData(userId);
                try
                {
                    userProfileData.UserId     = userId;
                    userProfileData.UserRoleId = userEntity.UserRoleID;
                    userProfileData.FirstName  = userEntity.FirstName;
                    userProfileData.LastName   = userEntity.LastName;
                    userProfileData.Email      = userEntity.Email;
                    userProfileData.PhoneNo    = userEntity.PhoneNo;
                }
                catch (Exception ex)
                {
                }
            }
            return(userProfileData);
        }
        public virtual bool UpdateUserProfileData(UserProfileData profile)
        {
            m_log.DebugFormat("[USERSTORAGE]: UpdateUserProfileData plugin request for {0} {1}", profile.ID, profile.Name);
            bool result = false;

            foreach (IUserDataPlugin plugin in m_plugins)
            {
                try
                {
                    plugin.UpdateUserProfile(profile);
                    result = true;
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat(
                        "[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}",
                        profile.FirstName, profile.SurName, plugin.Name, e.ToString());
                }
            }

            return(result);
        }
        public override void LogOffUser(UserProfileData theUser, string message)
        {
            RegionInfo SimInfo;

            try
            {
                SimInfo = this.m_regionsConnector.RequestNeighbourInfo(theUser.CurrentAgent.Handle);

                if (SimInfo == null)
                {
                    m_log.Error("[LOCAL LOGIN]: Region user was in isn't currently logged in");
                    return;
                }
            }
            catch (Exception)
            {
                m_log.Error("[LOCAL LOGIN]: Unable to look up region to log user off");
                return;
            }

            m_regionsConnector.LogOffUserFromGrid(SimInfo.RegionHandle, theUser.ID, theUser.CurrentAgent.SecureSessionID, "Logging you off");
        }
예제 #30
0
        //注册
        public static bool Register(UserProfile userInfo, out string errorMsg)
        {
            errorMsg = "";
            UserProfile regInfo = new UserProfile()
            {
                UserName = userInfo.UserName,
                Password = SecurityHelper.Encrypt(userInfo.Password),
                RoleId   = 1//权限角色
            };
            int             registerState;
            UserProfileData userPorfile = new UserProfileData();
            var             userList    = userPorfile.select(0, " username ", "username='******'", null);
            bool            isNewName   = true;

            if (userList.Count > 0)
            {
                isNewName = false;
                errorMsg  = "该用户名已注册";
                return(isNewName);
            }
            try
            {
                registerState = userPorfile.insert(regInfo);
                if (registerState > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errorMsg = "注册出错" + ex.ToString();
                return(false);
            }
        }
예제 #31
0
        public void SendTextBoxToUser(
            UUID avatarID, string message, int chatChannel, string name,
            UUID objectID, UUID ownerID)
        {
            ScenePresence sp = m_scene.GetScenePresence(avatarID);

            // XXX MCD Should test for child agent for other calls as well
            if (sp != null && !sp.IsChildAgent)
            {
                string          firstName    = "(unknown";
                string          lastName     = "user)";
                UserProfileData ownerProfile = m_scene.CommsManager.UserService.GetUserProfile(ownerID);

                if (ownerProfile != null)
                {
                    firstName = ownerProfile.FirstName;
                    lastName  = ownerProfile.SurName;
                }

                sp.ControllingClient.SendTextBoxRequest(
                    message, chatChannel, name, ownerID, firstName, lastName, objectID);
            }
        }
예제 #32
0
        public void SendDialogToUser(
            UUID avatarID, string objectName, UUID objectID, UUID ownerID,
            string message, UUID textureID, int ch, string[] buttonlabels)
        {
            ScenePresence sp = m_scene.GetScenePresence(avatarID);

            if (sp != null && !sp.IsChildAgent)
            {
                string          firstName    = "(unknown";
                string          lastName     = "user)";
                UserProfileData ownerProfile = m_scene.CommsManager.UserService.GetUserProfile(ownerID);

                if (ownerProfile != null)
                {
                    firstName = ownerProfile.FirstName;
                    lastName  = ownerProfile.SurName;
                }

                sp.ControllingClient.SendDialog(
                    objectName, objectID, ownerID, firstName, lastName,
                    message, textureID, ch, buttonlabels);
            }
        }
예제 #33
0
        public void T010_CreateUser()
        {
            UserProfileData u1 = NewUser(user1, fname1, lname1);
            UserProfileData u2 = NewUser(user2, fname2, lname2);
            UserProfileData u3 = NewUser(user3, fname3, lname3);

            // this is used to check whether null works here
            u3.Email = null;

            db.AddNewUserProfile(u1);
            db.AddNewUserProfile(u2);
            db.AddNewUserProfile(u3);
            UserProfileData u1a = db.GetUserByUUID(user1);
            UserProfileData u2a = db.GetUserByUUID(user2);
            UserProfileData u3a = db.GetUserByUUID(user3);

            Assert.That(user1, Is.EqualTo(u1a.ID), "Assert.That(user1,Is.EqualTo(u1a.ID))");
            Assert.That(user2, Is.EqualTo(u2a.ID), "Assert.That(user2,Is.EqualTo(u2a.ID))");
            Assert.That(user3, Is.EqualTo(u3a.ID), "Assert.That(user3,Is.EqualTo(u3a.ID))");

            // and one email test
            Assert.That(u3.Email, Is.Null);
        }
 public virtual bool UpdateUserProfile(UserProfileData profile)
 {
     ReplaceUserData(profile);
     return m_storage.UpdateUserProfileData(profile);
 }
 /// <summary>
 /// Saves a target agent to the database
 /// </summary>
 /// <param name="profile">The users profile</param>
 /// <returns>Successful?</returns>
 public bool CommitAgent(ref UserProfileData profile)
 {
     //m_log.DebugFormat("[USER MANAGER]: Committing agent {0} {1}", profile.Name, profile.ID);
     
     // TODO: how is this function different from setUserProfile?  -> Add AddUserAgent() here and commit both tables "users" and "agents"
     // TODO: what is the logic should be?
     bool ret = false;
     ret = AddUserAgent(profile.CurrentAgent);
     ret = ret & UpdateUserProfile(profile);
     return ret;
 }
예제 #36
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="commsManager"></param>
 /// <param name="userProfile"></param>
 public CachedUserInfo(IInventoryService invService, UserProfileData userProfile)
 {
     m_userProfile = userProfile;
     m_InventoryService = invService;
 }
 public void AddNewUserProfile(UserProfileData user) {}
예제 #38
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="commsManager"></param>
 /// <param name="userProfile"></param>
 public CachedUserInfo(CommunicationsManager commsManager, UserProfileData userProfile, List<FriendListItem> friendInfos)
 {
     m_commsManager = commsManager;
     m_userProfile = userProfile;
     _friends = friendInfos;
     this.IndexFriendPermissions();
 }
예제 #39
0
        public virtual void AddTemporaryUserProfile(UserProfileData userProfile)
        {
            DumpStatus("AddTemporaryUserProfile(entry)"); 

            AddToProfileCache(userProfile);
            foreach (IUserDataPlugin plugin in m_plugins)
            {
                plugin.AddTemporaryUserProfile(userProfile);
            }
            DumpStatus("AddTemporaryUserProfile(exit)");
        }
        /// <summary>
        /// Saves a target agent to the database
        /// </summary>
        /// <param name="profile">The users profile</param>
        /// <returns>Successful?</returns>
        public bool CommitAgent(ref UserProfileData profile)
        {
//            if (m_isUserServer) m_log.WarnFormat("[USER CACHE]: CommitAgent: {0} {1}", profile.ID, profile.CurrentAgent.SecureSessionID);

            // TODO: how is this function different from setUserProfile?  -> Add AddUserAgent() here and commit both tables "users" and "agents"
            // TODO: what is the logic should be?
            bool ret = false;
            ret = AddUserAgent(profile.CurrentAgent);
            ret = ret & UpdateUserProfile(profile);
            return ret;
        }
예제 #41
0
        public virtual bool UpdateUserProfile(UserProfileData profile)
        {
            bool result = false;

            lock (_userProfilesLock)
            {
                _cachedProfileData.Remove(profile.ID);
            }
            
            foreach (IUserDataPlugin plugin in m_plugins)
            {
                try
                {
                    plugin.UpdateUserProfile(profile);
                    result = true;
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat(
                        "[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}", 
                        profile.FirstName, profile.SurName, plugin.Name, e.ToString());
                }
            }
            
            return result;
        }
예제 #42
0
        /// <summary>
        /// Add a new user
        /// </summary>
        /// <param name="firstName">first name</param>
        /// <param name="lastName">last name</param>
        /// <param name="password">password</param>
        /// <param name="email">email</param>
        /// <param name="regX">location X</param>
        /// <param name="regY">location Y</param>
        /// <param name="SetUUID">UUID of avatar.</param>
        /// <returns>The UUID of the created user profile.  On failure, returns UUID.Zero</returns>
        public virtual UUID AddUser(
            string firstName, string lastName, string password, string email, uint regX, uint regY, UUID SetUUID)
        {
            string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);

            UserProfileData userProf = GetUserProfile(firstName, lastName);
            if (userProf != null)
            {
                m_log.Error("[USERSTORAGE]: Not creating user. User already exists ");
                return UUID.Zero;
            }

            UserProfileData user = new UserProfileData();
            user.HomeLocation = new Vector3(128, 128, 100);
            user.ID = SetUUID;
            user.FirstName = firstName;
            user.SurName = lastName;
            user.PasswordHash = md5PasswdHash;
            user.PasswordSalt = String.Empty;
            user.Created = Util.UnixTimeSinceEpoch();
            user.HomeLookAt = new Vector3(100, 100, 100);
            user.HomeRegionX = regX;
            user.HomeRegionY = regY;
            user.Email = email;

            foreach (IUserDataPlugin plugin in m_plugins)
            {
                try
                {
                    plugin.AddNewUserProfile(user);
                }
                catch (Exception e)
                {
                    m_log.Error("[USERSTORAGE]: Unable to add user via " + plugin.Name + "(" + e.ToString() + ")");
                }
            }

            userProf = GetUserProfile(firstName, lastName);
            if (userProf == null)
            {
                return UUID.Zero;
            }
            else
            {
                CreateInventorySkel(userProf);
                return userProf.ID;
            }
        }
 public void AddUser(UserProfileData profile)
 {
     m_log.DebugFormat("[USERSTORAGE]: AddUser plugin request for {0} {1}", profile.ID, profile.Name);
     foreach (IUserDataPlugin plugin in m_plugins)
     {
         try
         {
             plugin.AddNewUserProfile(profile);
         }
         catch (Exception e)
         {
             m_log.Error("[USERSTORAGE]: Unable to add user via " + plugin.Name + "(" + e.ToString() + ")");
         }
     }
 }
        public virtual bool UpdateUserProfileData(UserProfileData profile)
        {
            m_log.DebugFormat("[USERSTORAGE]: UpdateUserProfileData plugin request for {0} {1}", profile.ID, profile.Name);
            bool result = false;

            foreach (IUserDataPlugin plugin in m_plugins)
            {
                try
                {
                    plugin.UpdateUserProfile(profile);
                    result = true;
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat(
                        "[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}", 
                        profile.FirstName, profile.SurName, plugin.Name, e.ToString());
                }
            }
            
            return result;
        }
 public virtual bool UpdateUserProfile(UserProfileData data)
 {
     bool result = false;
     
     foreach (IUserDataPlugin plugin in m_plugins)
     {
         try
         {
             plugin.UpdateUserProfile(data);
             result = true;
         }
         catch (Exception e)
         {
             m_log.ErrorFormat(
                 "[USERSTORAGE]: Unable to set user {0} {1} via {2}: {3}", 
                 data.FirstName, data.SurName, plugin.Name, e.ToString());
         }
     }
     
     return result;
 }
        /// <summary>
        /// Temporary profiles are used for bot users, they have no persistence.
        /// </summary>
        /// <param name="userProfile">the bot user profile</param>
        public virtual void AddTemporaryUserProfile(UserProfileData userProfile)
        {
            AddToUserInfoCache(userProfile);

            lock (m_userDataLock)
            {
                if (m_tempDataByUUID.ContainsKey(userProfile.ID))
                    m_tempDataByUUID.Remove(userProfile.ID);
                m_tempDataByUUID.Add(userProfile.ID, userProfile);

                if (m_userDataByName.ContainsKey(userProfile.Name))
                    m_userDataByName.Remove(userProfile.Name);
                m_userDataByName.Add(userProfile.Name, userProfile);
            }
        }
        public void CreateAgent(UserProfileData profile, OSD request)
        {
            //m_log.DebugFormat("[USER CACHE]: Creating agent {0} {1}", profile.Name, profile.ID);
            
            UserAgentData agent = new UserAgentData();

            // User connection
            agent.AgentOnline = true;

            //if (request.Params.Count > 1)
            //{
            //    IPEndPoint RemoteIPEndPoint = (IPEndPoint)request.Params[1];
            //    agent.AgentIP = RemoteIPEndPoint.Address.ToString();
            //    agent.AgentPort = (uint)RemoteIPEndPoint.Port;
            //}

            // Generate sessions
            RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
            byte[] randDataS = new byte[16];
            byte[] randDataSS = new byte[16];
            rand.GetBytes(randDataS);
            rand.GetBytes(randDataSS);

            agent.SecureSessionID = new UUID(randDataSS, 0);
            agent.SessionID = new UUID(randDataS, 0);

            // Profile UUID
            agent.ProfileID = profile.ID;

            // Current location/position/alignment
            if (profile.CurrentAgent != null)
            {
                agent.Region = profile.CurrentAgent.Region;
                agent.Handle = profile.CurrentAgent.Handle;
                agent.Position = profile.CurrentAgent.Position;
                agent.LookAt = profile.CurrentAgent.LookAt;
            }
            else
            {
                agent.Region = profile.HomeRegionID;
                agent.Handle = profile.HomeRegion;
                agent.Position = profile.HomeLocation;
                agent.LookAt = profile.HomeLookAt;
            }

            // What time did the user login?
            agent.LoginTime = Util.UnixTimeSinceEpoch();
            agent.LogoutTime = 0;

            profile.CurrentAgent = agent;
        }
예제 #48
0
        /// <summary>
        /// Creates and initializes a new user agent - make sure to use CommitAgent when done to submit to the DB
        /// This method is only ever invoked by the User server (not regions).
        /// </summary>
        /// <param name="profile">The users profile</param>
        /// <param name="request">The users loginrequest</param>
        public void CreateAgent(UserProfileData profile, XmlRpcRequest request)
        {
            // m_log.DebugFormat("[USER CACHE]: Creating agent {0} {1}", profile.Name, profile.ID);
            
            UserAgentData agent = new UserAgentData();

            // User connection
            agent.AgentOnline = true;

            if (request.Params.Count > 1)
            {
                if (request.Params[1] != null)
                {
                    IPEndPoint RemoteIPEndPoint = (IPEndPoint)request.Params[1];
                    agent.AgentIP = RemoteIPEndPoint.Address.ToString();
                    agent.AgentPort = (uint)RemoteIPEndPoint.Port;
                }
            }

            // Generate sessions
            RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
            byte[] randDataS = new byte[16];
            byte[] randDataSS = new byte[16];
            rand.GetBytes(randDataS);
            rand.GetBytes(randDataSS);

            agent.SecureSessionID = new UUID(randDataSS, 0);
            agent.SessionID = new UUID(randDataS, 0);

            // Profile UUID
            agent.ProfileID = profile.ID;

            // Current location/position/alignment
            if (profile.CurrentAgent != null)
            {
                m_log.InfoFormat("[USER CACHE]: Creating agent {0} {1} at {2} {3} was {4} {5}", profile.Name, profile.ID, Util.RegionHandleToLocationString(profile.CurrentAgent.Handle), profile.CurrentAgent.Position, Util.RegionHandleToLocationString(agent.Handle), agent.Position);
                agent.Region = profile.CurrentAgent.Region;
                agent.Handle = profile.CurrentAgent.Handle;
                agent.Position = profile.CurrentAgent.Position;
                agent.LookAt = profile.CurrentAgent.LookAt;
            }
            else
            {
                m_log.InfoFormat("[USER CACHE]: Creating agent {0} {1} at HOME {2} {3} was {4} {5}", profile.Name, profile.ID, Util.RegionHandleToLocationString(profile.HomeRegion), profile.HomeLocation, Util.RegionHandleToLocationString(agent.Handle), agent.Position);
                agent.Region = profile.HomeRegionID;
                agent.Handle = profile.HomeRegion;
                agent.Position = profile.HomeLocation;
                agent.LookAt = profile.HomeLookAt;
            }

            // What time did the user login?
            agent.LoginTime = Util.UnixTimeSinceEpoch();
            agent.LogoutTime = 0;

            // if (m_isUserServer)
            //     m_log.WarnFormat("[USER CACHE]: Creating new agent data for {0} SSID={1} at {2} {3}", agent.ProfileID, agent.SecureSessionID, Util.RegionHandleToLocationString(agent.Handle), agent.Position); 

            profile.CurrentAgent = agent;
        }
        /// <summary>
        /// Add a new user
        /// </summary>
        /// <param name="firstName">first name</param>
        /// <param name="lastName">last name</param>
        /// <param name="password">password</param>
        /// <param name="email">email</param>
        /// <param name="regX">location X</param>
        /// <param name="regY">location Y</param>
        /// <param name="uuid">UUID of avatar.</param>
        /// <returns>The UUID of the created user profile.  On failure, returns UUID.Zero</returns>
        public virtual UUID AddUser(
            string firstName, string lastName, string password, string email, uint regX, uint regY, UUID uuid)
        {
            string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);

            UserProfileData userProf = GetUserProfile(firstName, lastName);
            if (userProf != null)
            {
                m_log.Error("[USERSTORAGE]: Not creating user. User already exists ");
                return UUID.Zero;
            }

            UserProfileData user = new UserProfileData();
            user.HomeLocation = new Vector3(128, 128, 100);
            user.ID = uuid;
            user.FirstName = firstName;
            user.SurName = lastName;
            user.PasswordHash = md5PasswdHash;
            user.PasswordSalt = String.Empty;
            user.Created = Util.UnixTimeSinceEpoch();
            user.HomeLookAt = new Vector3(100, 100, 100);
            user.HomeRegionX = regX;
            user.HomeRegionY = regY;
            user.Email = email;

            m_storage.AddUser(user);

            userProf = GetUserProfile(uuid);
            if (userProf == null)
            {
                return UUID.Zero;
            }
            else
            {
                CreateInventorySkel(userProf);
                return userProf.ID;
            }
        }
        private void CreateInventorySkel(UserProfileData userProf)
        {
            IInventoryProviderSelector inventorySelect = ProviderRegistry.Instance.Get<IInventoryProviderSelector>();
            IInventoryStorage storage = inventorySelect.GetProvider(userProf.ID);

            InventoryFolderBase folder = new InventoryFolderBase();

            UUID user = userProf.ID;

            folder.ParentID = UUID.Zero;
            folder.Owner = user;
            folder.ID = UUID.Random();
            folder.Name = "My Inventory";
            folder.Type = (short)AssetType.Folder;
            folder.Version = 1;
            storage.CreateFolder(folder);

            UUID rootFolder = folder.ID;

            folder = new InventoryFolderBase();
            folder.ParentID = rootFolder;
            folder.Owner = user;
            folder.ID = UUID.Random();
            folder.Name = "Animations";
            folder.Type = (short)AssetType.Animation;
            folder.Version = 1;
            storage.CreateFolder(folder);

            folder = new InventoryFolderBase();
            folder.ParentID = rootFolder;
            folder.Owner = user;
            folder.ID = UUID.Random();
            folder.Name = "Body Parts";
            folder.Type = (short)AssetType.Bodypart;
            folder.Version = 1;
            storage.CreateFolder(folder);

            folder = new InventoryFolderBase();
            folder.ParentID = rootFolder;
            folder.Owner = user;
            folder.ID = UUID.Random();
            folder.Name = "Calling Cards";
            folder.Type = (short)AssetType.CallingCard;
            folder.Version = 1;
            storage.CreateFolder(folder);

            folder = new InventoryFolderBase();
            folder.ParentID = rootFolder;
            folder.Owner = user;
            folder.ID = UUID.Random();
            folder.Name = "Clothing";
            folder.Type = (short)AssetType.Clothing;
            folder.Version = 1;
            storage.CreateFolder(folder);

            folder = new InventoryFolderBase();
            folder.ParentID = rootFolder;
            folder.Owner = user;
            folder.ID = UUID.Random();
            folder.Name = "Gestures";
            folder.Type = (short)AssetType.Gesture;
            folder.Version = 1;
            storage.CreateFolder(folder);

            folder = new InventoryFolderBase();
            folder.ParentID = rootFolder;
            folder.Owner = user;
            folder.ID = UUID.Random();
            folder.Name = "Landmarks";
            folder.Type = (short)AssetType.Landmark;
            folder.Version = 1;
            storage.CreateFolder(folder);

            folder = new InventoryFolderBase();
            folder.ParentID = rootFolder;
            folder.Owner = user;
            folder.ID = UUID.Random();
            folder.Name = "Lost And Found";
            folder.Type = (short)AssetType.LostAndFoundFolder;
            folder.Version = 1;
            storage.CreateFolder(folder);

            folder = new InventoryFolderBase();
            folder.ParentID = rootFolder;
            folder.Owner = user;
            folder.ID = UUID.Random();
            folder.Name = "Notecards";
            folder.Type = (short)AssetType.Notecard;
            folder.Version = 1;
            storage.CreateFolder(folder);

            folder = new InventoryFolderBase();
            folder.ParentID = rootFolder;
            folder.Owner = user;
            folder.ID = UUID.Random();
            folder.Name = "Objects";
            folder.Type = (short)AssetType.Object;
            folder.Version = 1;
            storage.CreateFolder(folder);

            folder = new InventoryFolderBase();
            folder.ParentID = rootFolder;
            folder.Owner = user;
            folder.ID = UUID.Random();
            folder.Name = "Photo Album";
            folder.Type = (short)AssetType.SnapshotFolder;
            folder.Version = 1;
            storage.CreateFolder(folder);

            folder = new InventoryFolderBase();
            folder.ParentID = rootFolder;
            folder.Owner = user;
            folder.ID = UUID.Random();
            folder.Name = "Scripts";
            folder.Type = (short)AssetType.LSLText;
            folder.Version = 1;
            storage.CreateFolder(folder);

            folder = new InventoryFolderBase();
            folder.ParentID = rootFolder;
            folder.Owner = user;
            folder.ID = UUID.Random();
            folder.Name = "Sounds";
            folder.Type = (short)AssetType.Sound;
            folder.Version = 1;
            storage.CreateFolder(folder);

            folder = new InventoryFolderBase();
            folder.ParentID = rootFolder;
            folder.Owner = user;
            folder.ID = UUID.Random();
            folder.Name = "Textures";
            folder.Type = (short)AssetType.Texture;
            folder.Version = 1;
            storage.CreateFolder(folder);

            folder = new InventoryFolderBase();
            folder.ParentID = rootFolder;
            folder.Owner = user;
            folder.ID = UUID.Random();
            folder.Name = "Trash";
            folder.Type = (short)AssetType.TrashFolder;
            folder.Version = 1;
            storage.CreateFolder(folder);
        }
예제 #51
0
        private static UserProfileData GetUserProfile( )
        {
            UserProfileData userProfile;

              bool isReady = false;
              lock ( UserProfiles )
              {
            isReady = UserProfiles.TryGetValue( UserId, out userProfile );
              }

              if ( !isReady )
              {
            TrackerDataSetTableAdapters.ProcsAdapter procAdapters =
              new TrackerDataSetTableAdapters.ProcsAdapter( );
            int? notUsed = null;

            bool? tempEventsModel = null;
            bool? showUserMessagesByDefault = null;
            bool? userMessagesSettingIsNew = null;
            string tempCoordFormat = null;
            string defHemisphereNS = null;
            string defHemisphereEW = null;

            procAdapters.GetUserProfile(
              UserId,
              ref notUsed,
              ref tempEventsModel,
              ref tempCoordFormat,
              ref defHemisphereNS,
              ref defHemisphereEW,
              ref showUserMessagesByDefault,
              ref userMessagesSettingIsNew
            );

            userProfile = new UserProfileData( );
            userProfile.IsSimpleEventsModel = tempEventsModel.Value;
            userProfile.CoordFormat = ( CoordFormat ) Enum.Parse( typeof( CoordFormat ), tempCoordFormat );
            userProfile.DefHemisphereNS = defHemisphereNS[0];
            userProfile.DefHemisphereEW = defHemisphereEW[0];
            userProfile.ShowUserMessagesByDefault = showUserMessagesByDefault.Value;
            userProfile.UserMessagesSettingIsNew = userMessagesSettingIsNew.Value;

            lock ( UserProfiles )
            {
              UserProfileData otherValues;
              if ( UserProfiles.TryGetValue( UserId, out otherValues ) )
              { // someone else added the value while we've been on DB call
            userProfile = otherValues;
              }
              else
              {
            UserProfiles.Add( UserId, userProfile );
              }
            }
              }

              return userProfile;
        }
 private void ReplaceUserData(UserProfileData profile)
 {
     lock (m_userDataLock)
     {
         if (m_userDataByUUID.Contains(profile.ID))
             m_userDataByUUID.Remove(profile.ID);
         if (m_userDataByName.ContainsKey(profile.Name))
             m_userDataByName.Remove(profile.Name);
         m_userDataByName.Add(profile.Name, profile);
         m_userDataByUUID.Add(profile.ID, new TimestampedItem<UserProfileData>(profile));
     }
 }
 public Uri GetUserUri(UserProfileData userProfile)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// Upgrade a UserProfileData to a CachedUserInfo.
        /// </summary>
        /// <param name="userProfile"></param>
        /// <param name="friends">friends can be null when called from the User grid server itself.</param>
        /// <returns></returns>
        protected CachedUserInfo NewCachedUserInfo(UserProfileData userProfile, List<FriendListItem> friends)
        {
//            if ((friends == null) && (m_commsManager.UserService != null))
//                friends = m_commsManager.UserService.GetUserFriendList(userProfile.ID);
            return new CachedUserInfo(m_commsManager, userProfile, friends);
        }
 public bool UpdateUserProfile(UserProfileData user) { return false; }
        /// <summary>
        /// Populate caches with the given user profile (allocate userInfo).
        /// </summary>
        /// <param name="profile"></param>
        protected CachedUserInfo AddToUserInfoCache(UserProfileData profile)
        {
            CachedUserInfo userInfo = NewCachedUserInfo(profile, null);

            AddToUserInfoCache(userInfo);
            return userInfo;
        }
        /// <summary>
        /// Add a new user
        /// </summary>
        /// <param name="firstName">first name</param>
        /// <param name="lastName">last name</param>
        /// <param name="password">password</param>
        /// <param name="email">email</param>
        /// <param name="regX">location X</param>
        /// <param name="regY">location Y</param>
        /// <param name="SetUUID">UUID of avatar.</param>
        /// <returns>The UUID of the created user profile.  On failure, returns UUID.Zero</returns>
        public virtual UUID AddUser(
            string firstName, string lastName, string password, string email, uint regX, uint regY, UUID SetUUID)
        {
            string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + String.Empty);

            UserProfileData user = new UserProfileData();
            user.HomeLocation = new Vector3(128, 128, 100);
            user.ID = SetUUID;
            user.FirstName = firstName;
            user.SurName = lastName;
            user.PasswordHash = md5PasswdHash;
            user.PasswordSalt = String.Empty;
            user.Created = Util.UnixTimeSinceEpoch();
            user.HomeLookAt = new Vector3(100, 100, 100);
            user.HomeRegionX = regX;
            user.HomeRegionY = regY;
            user.Email = email;

            foreach (IUserDataPlugin plugin in m_plugins)
            {
                try
                {
                    plugin.AddNewUserProfile(user);
                }
                catch (Exception e)
                {
                    m_log.Error("[USERSTORAGE]: Unable to add user via " + plugin.Name + "(" + e.ToString() + ")");
                }
            }

            UserProfileData userProf = GetUserProfile(firstName, lastName);
            if (userProf == null)
            {
                return UUID.Zero;
            }
            else
            {
                //
                // WARNING: This is a horrible hack
                // The purpose here is to avoid touching the user server at this point.
                // There are dragons there that I can't deal with right now.
                // diva 06/09/09
                //
                if (m_InventoryService != null)
                {
                    // local service (standalone)
                    m_log.Debug("[USERSTORAGE]: using IInventoryService to create user's inventory");
                    m_InventoryService.CreateUserInventory(userProf.ID);
                    InventoryFolderBase rootfolder = m_InventoryService.GetRootFolder(userProf.ID);
                    if (rootfolder != null)
                        userProf.RootInventoryFolderID = rootfolder.ID;
                }
                else if (m_commsManager.InterServiceInventoryService != null)
                {
                    // used by the user server
                    m_log.Debug("[USERSTORAGE]: using m_commsManager.InterServiceInventoryService to create user's inventory");
                    m_commsManager.InterServiceInventoryService.CreateNewUserInventory(userProf.ID);
                }

                return userProf.ID;
            }
        }
        /// <summary>
        /// Update an existing profile
        /// </summary>
        /// <param name="userProfile"></param>
        /// <returns>true if a user profile was found to update, false otherwise</returns>
        // Commented out for now.  The implementation needs to be improved by protecting against race conditions,
        // probably by making sure that the update doesn't use the UserCacheInfo.UserProfile directly (possibly via
        // returning a read only class from the cache).
//        public bool StoreProfile(UserProfileData userProfile)
//        {
//            lock (m_userProfilesById)
//            {
//                CachedUserInfo userInfo = GetUserDetails(userProfile.ID);
//
//                if (userInfo != null)
//                {
//                    userInfo.m_userProfile = userProfile;
//                    m_commsManager.UserService.UpdateUserProfile(userProfile);
//
//                    return true;
//                }
//            }
//
//            return false;
//        }
        
        /// <summary>
        /// Populate caches with the given user profile
        /// </summary>
        /// <param name="userProfile"></param>
        protected CachedUserInfo AddToCaches(UserProfileData userProfile)
        {
            CachedUserInfo createdUserInfo = new CachedUserInfo(m_InventoryService, userProfile);
            
            lock (m_userProfilesById)
            {
                m_userProfilesById[createdUserInfo.UserProfile.ID] = createdUserInfo;
                
                lock (m_userProfilesByName)
                {
                    m_userProfilesByName[createdUserInfo.UserProfile.Name] = createdUserInfo;
                }
            }
            
            return createdUserInfo;
        }
 /// <summary>
 /// Preloads User data into the region cache. Modules may use this service to add non-standard clients
 /// </summary>
 /// <param name="userData"></param>
 public void PreloadUserCache(UserProfileData userData)
 {
     AddToCaches(userData);
 }
 public virtual void AddTemporaryUserProfile(UserProfileData userProfile)
 {
     foreach (IUserDataPlugin plugin in m_plugins)
     {
         plugin.AddTemporaryUserProfile(userProfile);
     }
 }