コード例 #1
0
ファイル: AdminCommand.cs プロジェクト: stwehrli/IOnEx
        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
ファイル: BroadcastCommand.cs プロジェクト: stwehrli/IOnEx
        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
ファイル: DeleteUserCommand.cs プロジェクト: stwehrli/IOnEx
 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
ファイル: CommandManager.cs プロジェクト: stwehrli/IOnEx
        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
ファイル: UserCommand.cs プロジェクト: stwehrli/IOnEx
 void ICommand.Execute(CommandContext context, CallerContext callerContext, string[] args)
 {
     //ChatUser user = context.Repository.VerifyUserId(callerContext.UserId);
     Execute(context, callerContext, null, args);
 }
コード例 #8
0
ファイル: UserCommand.cs プロジェクト: stwehrli/IOnEx
 public abstract void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args);
コード例 #9
0
ファイル: HelpCommand.cs プロジェクト: stwehrli/IOnEx
 public void Execute(CommandContext context, CallerContext callerContext, string[] args)
 {
     context.NotificationService.ShowHelp();
 }
コード例 #10
0
ファイル: TestCommand.cs プロジェクト: stwehrli/IOnEx
 public override void Execute(CommandContext context, CallerContext callerContext, Client callingClient, string[] args)
 {
     context.NotificationService.Test(callingClient, "This is just a test!");
 }