private void ShowUser(ClientRequestInfo requestInfo)
{
if (requestInfo.Request.Arguments.ContainsHelpRequest)
{
StringBuilder helpMessage = new StringBuilder();
helpMessage.Append("Shows the current user information.");
helpMessage.AppendLine();
helpMessage.AppendLine();
helpMessage.Append(" Usage:");
helpMessage.AppendLine();
helpMessage.Append(" User -options");
helpMessage.AppendLine();
helpMessage.AppendLine();
helpMessage.Append(" Options:");
helpMessage.AppendLine();
helpMessage.Append(" -?".PadRight(20));
helpMessage.Append("Displays this help message");
helpMessage.AppendLine();
helpMessage.Append(" -actionable".PadRight(20));
helpMessage.Append("Returns results via an actionable event");
helpMessage.AppendLine();
helpMessage.AppendLine();
UpdateStatus(requestInfo.Sender.ClientID, UpdateType.Information, helpMessage.ToString());
}
else
{
// 1 2 3 4 5 6 7 8
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890
// Current user: ABC\john
// Client name: openPDCConsole
// From machine: JohnPC
// Connected time: xx days yy hours zz minutes ii seconds
// Authenticated: true
ClientInfo info = requestInfo.Sender;
string message = $" Current user: {info.ClientUser.Identity.Name.ToNonNullNorEmptyString("Undetermined")}\r\n" + $" Client name: {info.ClientName.ToNonNullNorEmptyString("Undetermined")}\r\n" + $" From machine: {info.MachineName.ToNonNullNorEmptyString("Undetermined")}\r\n" + $"Connected time: {(info.ConnectedAt > DateTime.MinValue ? (DateTime.UtcNow - info.ConnectedAt).ToElapsedTimeString() : m_remotingServer.RunTime.ToString())}\r\n" + $" Authenticated: {info.ClientUser.Identity.IsAuthenticated}";
UpdateStatus(requestInfo.Sender.ClientID, UpdateType.Information, message + "\r\n\r\n");
// Also allow consumers to directly consume message via event in response to a user info request
if (requestInfo.Request.Arguments.Exists("actionable"))
SendActionableResponse(requestInfo, true, null, message);
}
}