Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
 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);
 }
Пример #4
0
 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);
 }
Пример #5
0
 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);
 }
Пример #6
0
        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;
        }
Пример #7
0
 void ICommand.Execute(CommandContext context, CallerContext callerContext, string[] args)
 {
     //ChatUser user = context.Repository.VerifyUserId(callerContext.UserId);
     Execute(context, callerContext, null, args);
 }
Пример #8
0
 public abstract void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args);
Пример #9
0
 public void Execute(CommandContext context, CallerContext callerContext, string[] args)
 {
     context.NotificationService.ShowHelp();
 }
Пример #10
0
 public override void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args)
 {
     context.NotificationService.Test(callingClient, "This is just a test!");
 }