public override void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args) { if (!callingClient.IsAdmin) { //throw new InvalidOperationException("You are not an admin."); } ExecuteAdminOperation(context, callerContext, callingClient, args); }
public override void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args) { string messageText = String.Join(" ", args).Trim(); if (String.IsNullOrEmpty(messageText)) { throw new InvalidOperationException("What did you want to broadcast?"); } context.NotificationService.Broadcast(callingClient, messageText); }
public override void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args) { string message; try { string roleName = args[0]; string members = string.Join(",", System.Web.Security.Roles.GetUsersInRole(roleName)); message = "Users in role '" + roleName + "': " + members; } catch (Exception ex) { message = ex.ToString(); } context.NotificationService.Test(callingClient, message); }
public override void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args) { string message; try { string username = args[0]; message = "Deleted user " + username; System.Web.Security.Membership.DeleteUser(username); } catch (Exception ex) { message = ex.ToString(); } context.NotificationService.Test(callingClient, message); }
public override void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args) { string message; try { string username = args[0]; string roleName = args[1]; message = "Added user " + username + " to role " + roleName; System.Web.Security.Roles.AddUserToRole(username, roleName); } catch (Exception ex) { message = ex.ToString(); } context.NotificationService.Test(callingClient, message); }
public bool TryHandleCommand(string commandName, string[] args) { if (String.IsNullOrEmpty(commandName)) { return false; } commandName = commandName.Trim(); if (commandName.StartsWith("/")) { return false; } var context = new CommandContext { //Cache = _cache, NotificationService = _notificationService, Repository = _repository, //Service = _chatService }; var callerContext = new CallerContext { ConnectionId = _connectionId, UserId = _userId, ClientId = "", //UserAgent = _userAgent, RoomName = _roomName, }; ICommand command; try { MatchCommand(commandName, out command); } catch (CommandNotFoundException) { throw new InvalidOperationException(String.Format("'{0}' is not a valid command.", commandName)); } catch (CommandAmbiguityException e) { throw new InvalidOperationException(String.Format("'{0}' is ambiguous: {1}.", commandName, String.Join(", ", e.Ambiguities))); } command.Execute(context, callerContext, args); return true; }
void ICommand.Execute(CommandContext context, CallerContext callerContext, string[] args) { //ChatUser user = context.Repository.VerifyUserId(callerContext.UserId); Execute(context, callerContext, null, args); }
public abstract void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args);
public void Execute(CommandContext context, CallerContext callerContext, string[] args) { context.NotificationService.ShowHelp(); }
public override void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args) { context.NotificationService.Test(callingClient, "This is just a test!"); }