• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Utils.Environment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Diva.Utils.Environment的典型用法代码示例。如果您正苦于以下问题:C# Environment类的具体用法?C# Environment怎么用?C# Environment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Environment类属于Diva.Utils命名空间,在下文中一共展示了Environment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Handle

        public override byte[] Handle(string path, Stream requestData,
                IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            // path = /wifi/...
            //m_log.DebugFormat("[Wifi]: path = {0}", path);
            //m_log.DebugFormat("[Wifi]: ip address = {0}", httpRequest.RemoteIPEndPoint);
            //foreach (object o in httpRequest.Query.Keys)
            //    m_log.DebugFormat("  >> {0}={1}", o, httpRequest.Query[o]);

            string result = string.Empty;
            try
            {
                Request request = RequestFactory.CreateRequest(string.Empty, httpRequest, Localization.GetLanguageInfo(httpRequest.Headers.Get("accept-language")));
                Environment env = new Environment(request);

                result = m_WebApp.Services.LogoutRequest(env);

                httpResponse.ContentType = "text/html";
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[LOGOUT HANDLER]: Exception {0}: {1}", e.Message, e.StackTrace);
            }

            return WebAppUtils.StringToBytes(result);
        }
开发者ID:ffoliveira,项目名称:diva-distribution,代码行数:26,代码来源:WifiLogoutHandler.cs


示例2: InventoryGetRequest

        public string InventoryGetRequest(Environment env)
        {
            if (!m_WebApp.IsInstalled)
            {
                m_log.DebugFormat("[Wifi]: warning: someone is trying to access UserAccountGetRequest and Wifi isn't isntalled!");
                return m_WebApp.ReadFile(env, "index.html");
            }

            m_log.DebugFormat("[Wifi]: InventoryGetRequest");
            Request request = env.TheRequest;

            SessionInfo sinfo;
            if (TryGetSessionInfo(request, out sinfo))
            {
                env.Session = sinfo;
                InventoryTreeNode tree = m_InventoryService.GetInventoryTree(sinfo.Account.PrincipalID);
                List<object> loo = new List<object>();
                //foreach (InventoryTreeNode n in tree.Children) // skip the artificial first level
                //{
                //    m_log.DebugFormat("[XXX] Adding {0}", n.Name);
                //    loo.Add(n);
                //}
                loo.Add(tree);

                env.Data = loo;
                env.Flags = Flags.IsLoggedIn;
                env.State = State.InventoryListForm;
                return WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html"));
            }
            else
            {
                return m_WebApp.ReadFile(env, "index.html");
            }
        }
开发者ID:ffoliveira,项目名称:diva-distribution,代码行数:34,代码来源:Services.Inventory.cs


示例3: ForgotPasswordPostRequest

        public string ForgotPasswordPostRequest(Environment env, string email)
        {
            UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, email);
            if (account != null)
            {
                string token = m_AuthenticationService.GetToken(account.PrincipalID, 60);
                if (token != string.Empty)
                {
                    string url = m_WebApp.WebAddress + "/wifi/recover/" + token + "?email=" + HttpUtility.UrlEncode(email);

                    string message = string.Format("\n{0}\n{1}\n{2}",
                        string.Format(_("Your account is {0} {1}", env), account.FirstName, account.LastName),
                        _("Click here to reset your password:", env),
                        url);
                    if (SendEMail(email, _("Password Reset", env), message))
                        NotifyWithoutButton(env, _("Check your email. You must reset your password within 60 minutes.", env));
                    else
                        NotifyWithoutButton(env, _("Email could not be sent.", env));

                    return m_WebApp.ReadFile(env, "index.html");
                }
            }

            return m_WebApp.ReadFile(env, "index.html");
        }
开发者ID:ffoliveira,项目名称:diva-distribution,代码行数:25,代码来源:Services.PasswordRecovery.cs


示例4: UserAccountGetRequest

        public string UserAccountGetRequest(Environment env, UUID userID)
        {
            if (!m_WebApp.IsInstalled)
            {
                m_log.DebugFormat("[Wifi]: warning: someone is trying to access UserAccountGetRequest and Wifi isn't isntalled!");
                return m_WebApp.ReadFile(env, "index.html");
            }

            m_log.DebugFormat("[Wifi]: UserAccountGetRequest");
            Request request = env.TheRequest;

            SessionInfo sinfo;
            if (TryGetSessionInfo(request, out sinfo))
            {
                env.Session = sinfo;
                List<object> loo = new List<object>();
                loo.Add(sinfo.Account);
                env.Data = loo;
                env.Flags = Flags.IsLoggedIn;
                env.State = State.UserAccountForm;
                return WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html"));
            }
            else
            {
                return m_WebApp.ReadFile(env, "index.html");
            }
        }
开发者ID:ffoliveira,项目名称:diva-distribution,代码行数:27,代码来源:Services.ChangeUserAccount.cs


示例5: InstallPostRequest

        public string InstallPostRequest(Environment env, string password, string password2)
        {
            if (m_WebApp.IsInstalled)
            {
                m_log.DebugFormat("[Wifi]: warning: someone is trying to change the god password in InstallPostRequest!");
                return m_WebApp.ReadFile(env, "index.html");
            }

            m_log.DebugFormat("[Wifi]: InstallPostRequest");
            Request request = env.TheRequest;

            if (password == password2)
            {
                UserAccount god = m_UserAccountService.GetUserAccount(UUID.Zero, m_WebApp.AdminFirst, m_WebApp.AdminLast);
                if (god != null)
                {
                    m_AuthenticationService.SetPassword(god.PrincipalID, password);
                    // And this finishes the installation procedure
                    m_WebApp.IsInstalled = true;
                    NotifyWithoutButton(env,
                        string.Format(_("Your Wifi has been installed. The administrator account is {0} {1}", env),
                        m_WebApp.AdminFirst, m_WebApp.AdminLast));
                }
            }
            return m_WebApp.ReadFile(env, "index.html");
        }
开发者ID:ffoliveira,项目名称:diva-distribution,代码行数:26,代码来源:Services.Install.cs


示例6: GroupsDeleteGetRequest

        public string GroupsDeleteGetRequest(Environment env, UUID groupID)
        {
            m_log.DebugFormat("[Wifi]: GroupsDeleteGetRequest {0}", groupID);
            Request request = env.TheRequest;

            SessionInfo sinfo;
            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                if (m_GroupsService != null)
                {
                    env.Session = sinfo;
                    env.Flags = Flags.IsLoggedIn | Flags.IsAdmin;
                    env.State = State.GroupDeleteForm;
                    GroupRecord group = m_GroupsService.GetGroupRecord(groupID);
                    if (group != null)
                    {
                        List<object> loo = new List<object>();
                        loo.Add(group);
                        env.Data = loo;
                    }
                }
                else
                    m_log.WarnFormat("[Wifi]: No Groups service");

                return WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html"));
            }

            return m_WebApp.ReadFile(env, "index.html");
        }
开发者ID:ffoliveira,项目名称:diva-distribution,代码行数:30,代码来源:Services.GroupsManagement.cs


示例7: ConsoleSimulatorsRequest

        public string ConsoleSimulatorsRequest(Environment env)
        {
            m_log.Debug("[Wifi]: ConsoleSimulatorsRequest");
            string result = string.Empty;

            SessionInfo sinfo;
            if (TryGetSessionInfo(env.TheRequest, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                // Retrieve addresses of simulators (and the regions running on them)
                List<GridRegion> allRegions = m_GridService.GetRegionsByName(UUID.Zero, "", 200);
                List<GridRegion> hyperlinks = m_GridService.GetHyperlinks(UUID.Zero);
                IEnumerable<GridRegion> regions = allRegions.Except(hyperlinks);

                NameValueCollection simulators = new NameValueCollection();
                if (regions != null)
                {
                    foreach (GridRegion region in regions)
                    {
                        string address = region.ExternalHostName + ':' + region.HttpPort;
                        simulators.Add(address, region.RegionName);
                    }
                }

                // Create an XML document with the result data
                XmlDocument xmldoc = new XmlDocument();
                XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, "", "");
                xmldoc.AppendChild(xmlnode);

                XmlElement rootElement = xmldoc.CreateElement("Wifi");
                xmldoc.AppendChild(rootElement);

                XmlElement simulatorsElement = xmldoc.CreateElement("Simulators");
                rootElement.AppendChild(simulatorsElement);

                foreach (string address in simulators.AllKeys)
                {
                    XmlElement simElement = xmldoc.CreateElement("Simulator");
                    simElement.SetAttribute("HostAddress", address);
                    simulatorsElement.AppendChild(simElement);

                    foreach (string regionName in simulators.GetValues(address))
                    {
                        XmlElement regionElement = xmldoc.CreateElement("Region");
                        simElement.AppendChild(regionElement);

                        XmlElement nameElement = xmldoc.CreateElement("Name");
                        nameElement.AppendChild(xmldoc.CreateTextNode(regionName));
                        regionElement.AppendChild(nameElement);
                    }
                }

                result = xmldoc.InnerXml;
            }
            return result;
        }
开发者ID:ffoliveira,项目名称:diva-distribution,代码行数:56,代码来源:Services.Console.cs


示例8: NewAccountGetRequest

        public string NewAccountGetRequest(Environment env)
        {
            m_log.DebugFormat("[Wifi]: NewAccountGetRequest");
            Request request = env.TheRequest;

            env.State = State.NewAccountForm;
            env.Data = GetDefaultAvatarSelectionList();

            return m_WebApp.ReadFile(env, "index.html");
        }
开发者ID:JeffCost,项目名称:diva-distribution,代码行数:10,代码来源:Services.NewAccount.cs


示例9: UserAccountPostRequest

        public string UserAccountPostRequest(Environment env, UUID userID, string email, string oldpassword, string newpassword, string newpassword2)
        {
            if (!m_WebApp.IsInstalled)
            {
                m_log.DebugFormat("[Wifi]: warning: someone is trying to access UserAccountPostRequest and Wifi isn't isntalled!");
                return m_WebApp.ReadFile(env, "index.html");
            }
            m_log.DebugFormat("[Wifi]: UserAccountPostRequest");
            Request request = env.TheRequest;

            SessionInfo sinfo;
            if (TryGetSessionInfo(request, out sinfo))
            {
                env.Session = sinfo;
                // We get the userID, but we only allow changes to the account of this session
                List<object> loo = new List<object>();
                loo.Add(sinfo.Account);
                env.Data = loo;

                bool updated = false;
                if (email != string.Empty && email.Contains("@") && sinfo.Account.Email != email)
                {
                    sinfo.Account.Email = email;
                    m_UserAccountService.StoreUserAccount(sinfo.Account);
                    updated = true;
                }

                string encpass = OpenSim.Framework.Util.Md5Hash(oldpassword);
                if ((newpassword != string.Empty) && (newpassword == newpassword2) &&
                    m_AuthenticationService.Authenticate(sinfo.Account.PrincipalID, encpass, 30) != string.Empty)
                {
                    m_AuthenticationService.SetPassword(sinfo.Account.PrincipalID, newpassword);
                    updated = true;
                }

                if (updated)
                {
                    env.Flags = Flags.IsLoggedIn;
                    NotifyWithoutButton(env, _("Your account has been updated.", env));
                    m_log.DebugFormat("[Wifi]: Updated account for user {0}", sinfo.Account.Name);
                    return WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html"));
                }

                // nothing was updated, really
                env.Flags = Flags.IsLoggedIn;
                env.State = State.UserAccountForm;
                return WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html"));
            }
            else
            {
                m_log.DebugFormat("[Wifi]: Failed to get session info");
                return m_WebApp.ReadFile(env, "index.html");
            }
        }
开发者ID:ffoliveira,项目名称:diva-distribution,代码行数:54,代码来源:Services.ChangeUserAccount.cs


示例10: ConsoleHeartbeat

        public string ConsoleHeartbeat(Environment env)
        {
            m_log.DebugFormat("[Wifi]: ConsoleHeartbeat");
            SessionInfo sinfo;
            if (TryGetSessionInfo(env.TheRequest, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                // Reset session timer
                m_Sessions.Update(sinfo.Sid, sinfo, m_WebApp.SessionTimeout);
            }

            return string.Empty;
        }
开发者ID:ffoliveira,项目名称:diva-distribution,代码行数:13,代码来源:Services.Console.cs


示例11: ConsoleRequest

        public string ConsoleRequest(Environment env)
        {
            m_log.DebugFormat("[Wifi]: ConsoleRequest");
            SessionInfo sinfo;
            if (TryGetSessionInfo(env.TheRequest, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;
                env.Flags = Flags.IsLoggedIn | Flags.IsAdmin;
                env.State = State.Console;
                return WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html"));
            }

            return m_WebApp.ReadFile(env, "index.html");
        }
开发者ID:ffoliveira,项目名称:diva-distribution,代码行数:15,代码来源:Services.Console.cs


示例12: DefaultRequest

        public string DefaultRequest(Environment env)
        {
            m_log.DebugFormat("[Wifi]: DefaultRequest");

            SessionInfo sinfo;
            if (TryGetSessionInfo(env.TheRequest, out sinfo))
            {
                env.Session = sinfo;
                env.Flags = Flags.IsLoggedIn;
                env.State = State.Default;
                return WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "splash.html"));
            }

            string resourcePath = Localization.LocalizePath(env, "splash.html");
            Processor p = new Processor(m_WebApp.WifiScriptFace, env);
            return p.Process(WebAppUtils.ReadTextResource(resourcePath));
        }
开发者ID:ffoliveira,项目名称:diva-distribution,代码行数:17,代码来源:Services.Default.cs


示例13: RegionManagementBroadcastPostRequest

        public string RegionManagementBroadcastPostRequest(Environment env, string message)
        {
            Request request = env.TheRequest;

            SessionInfo sinfo;
            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;

                string url = m_WebApp.LoginURL;
                Hashtable hash = new Hashtable();
                if (m_ServerAdminPassword == null)
                {
                    m_log.Debug("[RegionManagementBroadcastPostRequest] No remote admin password was set in .ini file");
                }

                hash["password"] = m_ServerAdminPassword;
                hash["message"] = message;
                IList paramList = new ArrayList();
                paramList.Add(hash);
                XmlRpcRequest xmlrpcReq = new XmlRpcRequest("admin_broadcast", paramList);

                XmlRpcResponse response = null;
                try
                {
                    response = xmlrpcReq.Send(url, 10000);
                    env.Flags = Flags.IsAdmin | Flags.IsLoggedIn;
                    env.State = State.RegionManagementSuccessful;
                }
                catch (Exception e)
                {
                    m_log.Debug("[Wifi]: Exception (3) " + e.Message);
                    env.Flags = Flags.IsAdmin | Flags.IsLoggedIn;
                    env.State = State.RegionManagementUnsuccessful;
                }

                return WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html"));
            }

            return m_WebApp.ReadFile(env, "index.html");
        }
开发者ID:ffoliveira,项目名称:diva-distribution,代码行数:42,代码来源:Services.RegionManagement.cs


示例14: GroupsDeletePostRequest

        public string GroupsDeletePostRequest(Environment env, UUID groupID)
        {
            m_log.DebugFormat("[Wifi]: GroupsDeletePostRequest {0}", groupID);
            Request request = env.TheRequest;

            SessionInfo sinfo;
            if (TryGetSessionInfo(request, out sinfo) &&
                (sinfo.Account.UserLevel >= m_WebApp.AdminUserLevel))
            {
                env.Session = sinfo;
                m_GroupsService.DeleteGroup(groupID);

                env.Flags = Flags.IsAdmin | Flags.IsLoggedIn;
                NotifyWithoutButton(env, _("The group has been deleted.", env));
                m_log.DebugFormat("[Wifi]: Deleted group {0}", groupID);

                return WebAppUtils.PadURLs(env, sinfo.Sid, m_WebApp.ReadFile(env, "index.html"));
            }

            return m_WebApp.ReadFile(env, "index.html");
        }
开发者ID:JeffCost,项目名称:diva-distribution,代码行数:21,代码来源:Services.GroupsManagement.cs


示例15: LoginRequest

        public string LoginRequest(Environment env, string first, string last, string password)
        {
            if (!m_WebApp.IsInstalled)
            {
                m_log.DebugFormat("[Wifi]: warning: someone is trying to access LoginRequest and Wifi isn't installed!");
                return m_WebApp.ReadFile(env, "index.html");
            }

            m_log.DebugFormat("[Wifi]: LoginRequest {0} {1}", first, last);
            Request request = env.TheRequest;
            string encpass = OpenSim.Framework.Util.Md5Hash(password);

            string notification;
            string authtoken = null;
            UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, first, last);
            if (account != null)
                authtoken = m_AuthenticationService.Authenticate(account.PrincipalID, encpass, 30);
            if (string.IsNullOrEmpty(authtoken))
                notification = _("Login failed.", env);
            else
            {
                // Successful login
                SessionInfo sinfo;
                sinfo.IpAddress = request.IPEndPoint.Address.ToString();
                sinfo.Sid = authtoken;
                sinfo.Account = account;
                sinfo.Notify = new NotificationData();
                m_Sessions.Add(authtoken, sinfo, m_WebApp.SessionTimeout);
                env.TheRequest.Query["sid"] = authtoken;
                env.Session = sinfo;

                List<object> loo = new List<object>();
                loo.Add(account);
                env.Data = loo;
                env.Flags = Flags.IsLoggedIn;
                notification = string.Format(_("Welcome to {0}!", env), m_WebApp.GridName);
            }
            NotifyWithoutButton(env, notification);
            return WebAppUtils.PadURLs(env, authtoken, m_WebApp.ReadFile(env, "index.html"));
        }
开发者ID:ffoliveira,项目名称:diva-distribution,代码行数:40,代码来源:Services.LoginLogout.cs


示例16: Handle

        public override byte[] Handle(string path, Stream requestData,
                IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
        {
            // This is the content type of the response. Don't forget to set it to this in all your handlers.
            httpResponse.ContentType = "text/html";

            string resource = GetParam(path);
            //m_log.DebugFormat("[NOTIFY HANDLER]: resource {1}", resource);
            Request request = RequestFactory.CreateRequest(resource, httpRequest, Localization.GetLanguageInfo(httpRequest.Headers.Get("accept-language")));
            Environment env = new Environment(request);

            string result = string.Empty;
            try
            {
                result = m_WebApp.Services.NotifyRequest(env);
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[NOTIFY HANDLER]: Exception {0}: {1}", e.Message, e.StackTrace);
            }

            return WebAppUtils.StringToBytes(result);
        }
开发者ID:ffoliveira,项目名称:diva-distribution,代码行数:23,代码来源:WifiNotifyHandler.cs


示例17: GetUserName

        public string GetUserName(Environment env)
        {
            SessionInfo sinfo = env.Session;
            if (sinfo.Account != null)
            {
                return sinfo.Account.FirstName + " " + sinfo.Account.LastName;
            }

            return _("Who are you?", env);
        }
开发者ID:MelanieT,项目名称:diva-distribution,代码行数:10,代码来源:WifiScriptFace.cs


示例18: GetUserImage

        public string GetUserImage(Environment env)
        {
            SessionInfo sinfo = env.Session;
            if (sinfo.Account != null)
            {
                // TODO
                return "/wifi/images/abstract-cool.jpg";
            }

            // TODO
            return "/wifi/images/abstract-cool.jpg";
        }
开发者ID:MelanieT,项目名称:diva-distribution,代码行数:12,代码来源:WifiScriptFace.cs


示例19: GetUserEmail

        public string GetUserEmail(Environment env)
        {
            SessionInfo sinfo = env.Session;
            if (sinfo.Account != null)
            {
                if (sinfo.Account.Email == string.Empty)
                    return _("No email on file", env);

                return sinfo.Account.Email;
            }

            return _("Who are you?", env);
        }
开发者ID:MelanieT,项目名称:diva-distribution,代码行数:13,代码来源:WifiScriptFace.cs


示例20: GetRefresh

        public string GetRefresh(Environment env)
        {
            const string redirect = "<meta http-equiv=\"refresh\" content=\"{0}; URL={1}/?sid={2}\" />";

            if (env.State == State.Notification)
            {
                SessionInfo sinfo = env.Session;
                if (sinfo.Sid != null && sinfo.Notify.RedirectDelay >= 0)
                    return string.Format(redirect, sinfo.Notify.RedirectDelay, sinfo.Notify.RedirectUrl, sinfo.Sid);
            }
            return string.Empty;
        }
开发者ID:MelanieT,项目名称:diva-distribution,代码行数:12,代码来源:WifiScriptFace.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Client.RequestBody类代码示例发布时间:2022-05-24
下一篇:
C# EF.CokeDataContext类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap