本文整理汇总了C#中Diva.Utils.Environment类的典型用法代码示例。如果您正苦于以下问题:C# Environment类的具体用法?C# Environment怎么用?C# Environment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Environment类属于Diva.Utils命名空间,在下文中一共展示了Environment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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");
}
}
示例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");
}
示例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");
}
}
示例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");
}
示例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");
}
示例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;
}
示例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");
}
示例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");
}
}
示例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;
}
示例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");
}
示例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));
}
示例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");
}
示例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");
}
示例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"));
}