当前位置: 首页>>代码示例>>C#>>正文


C# WebInterface.Redirect方法代码示例

本文整理汇总了C#中WhiteCore.Modules.Web.WebInterface.Redirect方法的典型用法代码示例。如果您正苦于以下问题:C# WebInterface.Redirect方法的具体用法?C# WebInterface.Redirect怎么用?C# WebInterface.Redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WhiteCore.Modules.Web.WebInterface的用法示例。


在下文中一共展示了WebInterface.Redirect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Fill

        public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                               OSHttpResponse httpResponse, Dictionary<string, object> requestParameters,
                                               ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary<string, object>();

            string username = filename.Split('/').LastOrDefault();
            UserAccount account = null;
            if (httpRequest.Query.ContainsKey("userid"))
            {
                string userid = httpRequest.Query["userid"].ToString();

                account = webInterface.Registry.RequestModuleInterface<IUserAccountService>().
                                       GetUserAccount(null, UUID.Parse(userid));
            }
            else if (httpRequest.Query.ContainsKey("name"))
            {
                string name = httpRequest.Query.ContainsKey("name") ? httpRequest.Query["name"].ToString() : username;
                name = name.Replace('.', ' ');
                name = name.Replace("%20", " ");
                account = webInterface.Registry.RequestModuleInterface<IUserAccountService>().
                                       GetUserAccount(null, name);
            }
            else
            {
                username = username.Replace("%20", " ");
                webInterface.Redirect(httpResponse, "/webprofile/?name=" + username);
                return vars;
            }

            if (account == null)
                return vars;

			/* Allow access to the system user info - needed for Estate owner Profiles of regions
            if ( Utilities.IsSystemUser(account.PrincipalID) )
				return vars;
            */

            vars.Add("UserName", account.Name);
            //  TODO: User Profile inworld shows this as the standard mm/dd/yyyy
            //  Do we want this to be localised into the users Localisation or keep it as standard ?
            //
            //  vars.Add("UserBorn", Culture.LocaleDate(Util.ToDateTime(account.Created)));
            vars.Add("UserBorn", Util.ToDateTime(account.Created).ToShortDateString());

            IUserProfileInfo profile = Framework.Utilities.DataManager.RequestPlugin<IProfileConnector>().
                                              GetUserProfile(account.PrincipalID);
            string picUrl = "../images/icons/no_avatar.jpg";
            if (profile != null)
            {
                vars.Add ("UserType", profile.MembershipGroup == "" ? "Resident" : profile.MembershipGroup);

                if (profile.Partner != UUID.Zero)
                {
                    account = webInterface.Registry.RequestModuleInterface<IUserAccountService> ().
                                           GetUserAccount (null, profile.Partner);
                    vars.Add ("UserPartner", account.Name);
                } else
                    vars.Add ("UserPartner", "No partner");
                vars.Add ("UserAboutMe", profile.AboutText == "" ? "Nothing here" : profile.AboutText);
                IWebHttpTextureService webhttpService =
                    webInterface.Registry.RequestModuleInterface<IWebHttpTextureService> ();
                if (webhttpService != null && profile.Image != UUID.Zero)
                    picUrl = webhttpService.GetTextureURL (profile.Image);
            } else
            {
                // no profile yet
                vars.Add ("UserType", "Guest");
                vars.Add ("UserPartner", "Not specified yet");
                vars.Add ("UserAboutMe", "Nothing here yet");

            }
            vars.Add ("UserPictureURL", picUrl);

            // TODO:  This is only showing online status if you are logged in ??
            UserAccount ourAccount = Authenticator.GetAuthentication(httpRequest);
            if (ourAccount != null)
            {
                IFriendsService friendsService = webInterface.Registry.RequestModuleInterface<IFriendsService>();
                var friends = friendsService.GetFriends(account.PrincipalID);
                UUID friendID = UUID.Zero;
                if (friends.Any(f => UUID.TryParse(f.Friend, out friendID) && friendID == ourAccount.PrincipalID))
                {
                    IAgentInfoService agentInfoService =
                        webInterface.Registry.RequestModuleInterface<IAgentInfoService>();
                    IGridService gridService = webInterface.Registry.RequestModuleInterface<IGridService>();
                    UserInfo ourInfo = agentInfoService.GetUserInfo(account.PrincipalID.ToString());
                    if (ourInfo != null && ourInfo.IsOnline)
                        vars.Add("OnlineLocation", gridService.GetRegionByUUID(null, ourInfo.CurrentRegionID).RegionName);
                    vars.Add("UserIsOnline", ourInfo != null && ourInfo.IsOnline);
                    vars.Add("IsOnline",
                             ourInfo != null && ourInfo.IsOnline
                                 ? translator.GetTranslatedString("Online")
                                 : translator.GetTranslatedString("Offline"));
                }
                else
                {
                    vars.Add("OnlineLocation", "");
                    vars.Add("UserIsOnline", false);
//.........这里部分代码省略.........
开发者ID:EnricoNirvana,项目名称:WhiteCore-Dev,代码行数:101,代码来源:index.cs

示例2: Fill

        public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
            OSHttpResponse httpResponse, Dictionary<string, object> requestParameters,
            ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary<string, object>();

            string error = "";
            UUID user = httpRequest.Query.ContainsKey("userid")
                            ? UUID.Parse(httpRequest.Query["userid"].ToString())
                            : UUID.Parse(requestParameters["userid"].ToString());

            IUserAccountService userService = webInterface.Registry.RequestModuleInterface<IUserAccountService>();
            var agentService = Framework.Utilities.DataManager.RequestPlugin<IAgentConnector>();
            UserAccount account = userService.GetUserAccount(null, user);
            IAgentInfo agent = agentService.GetAgent(user);
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitPasswordChange")
            {
                string password = requestParameters["password"].ToString();
                string passwordconf = requestParameters["passwordconf"].ToString();

                if (password != passwordconf)
                    response = "Passwords do not match";
                else
                {
                    IAuthenticationService authService =
                        webInterface.Registry.RequestModuleInterface<IAuthenticationService>();
                    if (authService != null)
                        response = authService.SetPassword(user, "UserAccount", password)
                                       ? "Successfully set password"
                                       : "Failed to set your password, try again later";
                    else
                        response = "No authentication service was available to change your password";
                }
                return null;
            }
            else if (requestParameters.ContainsKey("Submit") &&
                     requestParameters["Submit"].ToString() == "SubmitEmailChange")
            {
                string email = requestParameters["email"].ToString();

                if (userService != null)
                {
                    account.Email = email;
                    userService.StoreUserAccount(account);
                    response = "Successfully updated email";
                }
                else
                    response = "No authentication service was available to change your password";
                return null;
            }
            else if (requestParameters.ContainsKey("Submit") &&
                     requestParameters["Submit"].ToString() == "SubmitDeleteUser")
            {
                string username = requestParameters["username"].ToString();
                response = "Deleted user successfully";
                if (username == account.Name)
                    userService.DeleteUser(account.PrincipalID, account.Name, "", false, false);
                else
                    response = "The user name did not match";
                return null;
            }
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitTempBanUser")
            {
                int timeDays = int.Parse(requestParameters["TimeDays"].ToString());
                int timeHours = int.Parse(requestParameters["TimeHours"].ToString());
                int timeMinutes = int.Parse(requestParameters["TimeMinutes"].ToString());
                agent.Flags |= IAgentFlags.TempBan;
                DateTime until = DateTime.Now.AddDays(timeDays).AddHours(timeHours).AddMinutes(timeMinutes);
                agent.OtherAgentInformation["TemperaryBanInfo"] = until;
                agentService.UpdateAgent(agent);
                error = "User has been banned.";
            }
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitBanUser")
            {
                agent.Flags |= IAgentFlags.PermBan;
                agentService.UpdateAgent(agent);
                error = "User has been banned.";
            }
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitUnbanUser")
            {
                agent.Flags &= ~IAgentFlags.TempBan;
                agent.Flags &= ~IAgentFlags.PermBan;
                agent.OtherAgentInformation.Remove("TemperaryBanInfo");
                agentService.UpdateAgent(agent);
                error = "User has been unbanned.";
            }
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitLoginAsUser")
            {
                Authenticator.ChangeAuthentication(httpRequest, account);
                webInterface.Redirect(httpResponse, "/");
                return vars;
            }
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitKickUser")
//.........这里部分代码省略.........
开发者ID:NanaYngvarrdottir,项目名称:WhiteCore-Dev,代码行数:101,代码来源:edit_user.cs

示例3: Fill

        public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
            OSHttpResponse httpResponse, Dictionary<string, object> requestParameters,
            ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary<string, object>();

            string username = filename.Split('/').LastOrDefault();
            UserAccount account = null;
            if (httpRequest.Query.ContainsKey("userid"))
            {
                string userid = httpRequest.Query["userid"].ToString();

                account = webInterface.Registry.RequestModuleInterface<IUserAccountService>().
                                       GetUserAccount(null, UUID.Parse(userid));
            }
            else if (httpRequest.Query.ContainsKey("name"))
            {
                string name = httpRequest.Query.ContainsKey("name") ? httpRequest.Query["name"].ToString() : username;
                name = name.Replace('.', ' ');
                name = name.Replace("%20", " ");
                account = webInterface.Registry.RequestModuleInterface<IUserAccountService>().
                                       GetUserAccount(null, name);
            }
            else
            {
                username = username.Replace("%20", " ");
                webInterface.Redirect(httpResponse, "/regionprofile/?name=" + username);
                return vars;
            }

            if (account == null)
                return vars;

            var libraryOwner = new UUID(Constants.LibraryOwner);
            var realestateOwner = new UUID(Constants.RealEstateOwnerUUID);

            if ( (account.PrincipalID == libraryOwner) || (account.PrincipalID == realestateOwner) )
                return vars;

            vars.Add("UserName", account.Name);
            //vars.Add("UserBorn", Util.ToDateTime(account.Created).ToShortDateString());
            vars.Add("UserBorn", Culture.LocaleDate(Util.ToDateTime(account.Created)));

            IUserProfileInfo profile = Framework.Utilities.DataManager.RequestPlugin<IProfileConnector>().
                                              GetUserProfile(account.PrincipalID);
            vars.Add("UserType", profile.MembershipGroup == "" ? "Resident" : profile.MembershipGroup);
            if (profile != null)
            {
                if (profile.Partner != UUID.Zero)
                {
                    account = webInterface.Registry.RequestModuleInterface<IUserAccountService>().
                                           GetUserAccount(null, profile.Partner);
                    vars.Add("UserPartner", account.Name);
                }
                else
                    vars.Add("UserPartner", "No partner");
                vars.Add("UserAboutMe", profile.AboutText == "" ? "Nothing here" : profile.AboutText);
                string url = "../images/icons/no_picture.jpg";
                IWebHttpTextureService webhttpService =
                    webInterface.Registry.RequestModuleInterface<IWebHttpTextureService>();
                if (webhttpService != null && profile.Image != UUID.Zero)
                    url = webhttpService.GetTextureURL(profile.Image);
                vars.Add("UserPictureURL", url);
            }
            UserAccount ourAccount = Authenticator.GetAuthentication(httpRequest);
            if (ourAccount != null)
            {
                IFriendsService friendsService = webInterface.Registry.RequestModuleInterface<IFriendsService>();
                var friends = friendsService.GetFriends(account.PrincipalID);
                UUID friendID = UUID.Zero;
                if (friends.Any(f => UUID.TryParse(f.Friend, out friendID) && friendID == ourAccount.PrincipalID))
                {
                    IAgentInfoService agentInfoService =
                        webInterface.Registry.RequestModuleInterface<IAgentInfoService>();
                    IGridService gridService = webInterface.Registry.RequestModuleInterface<IGridService>();
                    UserInfo ourInfo = agentInfoService.GetUserInfo(account.PrincipalID.ToString());
                    if (ourInfo != null && ourInfo.IsOnline)
                        vars.Add("OnlineLocation", gridService.GetRegionByUUID(null, ourInfo.CurrentRegionID).RegionName);
                    vars.Add("UserIsOnline", ourInfo != null && ourInfo.IsOnline);
                    vars.Add("IsOnline",
                             ourInfo != null && ourInfo.IsOnline
                                 ? translator.GetTranslatedString("Online")
                                 : translator.GetTranslatedString("Offline"));
                }
                else
                {
                    vars.Add("OnlineLocation", "");
                    vars.Add("UserIsOnline", false);
                    vars.Add("IsOnline", translator.GetTranslatedString("Offline"));
                }
            }
            else
            {
                vars.Add("OnlineLocation", "");
                vars.Add("UserIsOnline", false);
                vars.Add("IsOnline", translator.GetTranslatedString("Offline"));
            }

            // Menu Region
//.........这里部分代码省略.........
开发者ID:BillBarnhill,项目名称:WhiteCore-Dev,代码行数:101,代码来源:owner.cs

示例4: Fill


//.........这里部分代码省略.........
            // Ban user
            if (requestParameters.ContainsKey ("Submit") &&
                requestParameters ["Submit"].ToString () == "SubmitBanUser") {
                if (agent != null) {
                    agent.Flags |= IAgentFlags.PermBan;
                    agentService.UpdateAgent (agent);
                    response = "User has been banned.";
                } else
                    response = "Agent information is not available! Has the user logged in yet?";

                return null;
            }

            //UnBan user
            if (requestParameters.ContainsKey ("Submit") &&
                requestParameters ["Submit"].ToString () == "SubmitUnbanUser") {

                if (agent != null) {
                    agent.Flags &= ~IAgentFlags.TempBan;
                    agent.Flags &= ~IAgentFlags.PermBan;
                    agent.OtherAgentInformation.Remove ("Temporary BanInfo");
                    agentService.UpdateAgent (agent);
                    response = "User has been unbanned.";
                } else
                    response = "Agent information is not available! Has the user logged in yet?";

                return null;
            }

            // Login as user
            if (requestParameters.ContainsKey ("Submit") &&
                requestParameters ["Submit"].ToString () == "SubmitLoginAsUser") {
                Authenticator.ChangeAuthentication (httpRequest, account);
                webInterface.Redirect (httpResponse, "/");
                return vars;
            }

            // Kick user
            if (requestParameters.ContainsKey ("Submit") &&
                requestParameters ["Submit"].ToString () == "SubmitKickUser") {
                string message = requestParameters ["KickMessage"].ToString ();
                if (account != null) {
                    IGridWideMessageModule messageModule =
                        webInterface.Registry.RequestModuleInterface<IGridWideMessageModule> ();
                    if (messageModule != null)
                        messageModule.KickUser (account.PrincipalID, message);
                    response = "User has been kicked.";
                } else
                    response = "Unable to determine user to  kick!";
                return null;
            }

            // Message user
            if (requestParameters.ContainsKey ("Submit") &&
                requestParameters ["Submit"].ToString () == "SubmitMessageUser") {
                string message = requestParameters ["Message"].ToString ();
                if (account != null) {
                    IGridWideMessageModule messageModule =
                        webInterface.Registry.RequestModuleInterface<IGridWideMessageModule> ();
                    if (messageModule != null) {
                        messageModule.MessageUser (account.PrincipalID, message);
                        response = "User has been sent the message.";
                    }
                } else 
                    response = "User account details are unavailable to send the message!";
开发者ID:WhiteCoreSim,项目名称:WhiteCore-Dev,代码行数:66,代码来源:edit_user.cs


注:本文中的WhiteCore.Modules.Web.WebInterface.Redirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。