Beispiel #1
0
 public CommandModel(Command cmd)
     : base(cmd)
 {
     if (cmd != null)
     {
         Application_Id = cmd.Application_Id;
         Name = cmd.Name;
         Description = cmd.Description;
         CommandType = cmd.CommandType;
         ActionName = cmd.ActionName;
         Money = cmd.Money;
     }
 }
 public CommandViewModel(Command cmd, RoomWindowViewModel owner, Action<SecureCommandArgs> execute, Func<SecureCommandArgs, bool> canExecute)
     : base(cmd)
 {
     if (cmd != null)
     {
         name.SetValue(cmd.Name);
         description.SetValue(cmd.Description);
         money.SetValue(cmd.Money.HasValue ? cmd.Money.Value : 0);
         commandType.SetValue(cmd.CommandType);
         SecureCommand = new SecureCommand(SecureCommandExecute, CanSecureCommandExecute) { Owner = owner };
     }
     this.execute = execute;
     this.canExecute = canExecute;
 }
Beispiel #3
0
 private void CheckRoleCommand(int appid, int userId, RoleCommand rc)
 {
     var cmd = new Command { Id = rc.Command_Id };
     int cmdIdToCheck = -1;
     modelAccesser.Get<Command>(cmd);
     switch (cmd.CommandType)
     {
         case BuiltIns.BackendCommandType:
             cmdIdToCheck = BuiltIns.DefineBackendCommandCommand.Id;
             break;
         case BuiltIns.FrontendCommandType:
             cmdIdToCheck = BuiltIns.DefineFrontendCommandCommand.Id;
             break;
         case BuiltIns.UserCommandType:
             cmdIdToCheck = BuiltIns.DefineUserCommandCommand.Id;
             break;
     }
     CheckCommand(appid, rc.Application_Id, userId, cmdIdToCheck, BuiltIns.AllRole.Id);
 }
Beispiel #4
0
        private bool HasCommand(int currentAppId, int cmdTargetAppId, int userId, int cmdId, int targetRoleId)
        {
            if (currentAppId <= 0 || currentAppId == BuiltIns.AllApplication.Id)
            {
                return false;
            }
            //When calling from management portal, currentAppId is BuiltIns.BackendApplication.Id
            //when calling from other applications, currentAppId == cmdTargetAppId or BuiltIns.AllApplication.Id == currentAppId
            if (currentAppId == BuiltIns.BackendApplication.Id
                || currentAppId == cmdTargetAppId
                || cmdTargetAppId == BuiltIns.AllApplication.Id)
            {

                Command cmd = new Command { Id = cmdId };
                modelAccesser.Get<Command>(cmd);
                if (cmd.Loaded)
                {
                    switch (cmd.CommandType)
                    {
                        case BuiltIns.BackendCommandType:
                            if (currentAppId != BuiltIns.BackendApplication.Id)
                            {
                                return false;
                            }
                            break;
                        default:
                            break;
                    }
                }
                return modelAccesser.ExecuteSPReturn("HasCommand", new List<SPParameter>{
                new SPParameter{ Direction= System.Data.ParameterDirection.Input, Name = "userid", Type= System.Data.DbType.Int32, Value=userId},                
                new SPParameter{ Direction= System.Data.ParameterDirection.Input, Name = "cmdid", Type= System.Data.DbType.Int32, Value=cmdId},
                new SPParameter{ Direction= System.Data.ParameterDirection.Input, Name = "targetappid", Type= System.Data.DbType.Int32, Value=cmdTargetAppId},
                new SPParameter{ Direction= System.Data.ParameterDirection.Input, Name = "targetroleid", Type= System.Data.DbType.Int32, Value=targetRoleId},
            }) > 0;
            }
            return false;

        }
Beispiel #5
0
 public Command GetCommand(int appid, int userId, string token, int id)
 {
     try
     {
         CheckToken(appid, userId, token);
         Command command = new Command { Id = id };
         modelAccesser.Get(command);
         return command.Loaded ? command : null;
     }
     catch (Exception)
     {
         throw new DatabaseException();
     }
 }
Beispiel #6
0
 public Command AddCommand(int appid, int userId, string token, Command command)
 {
     try
     {
         CheckToken(appid, userId, token);
         CheckCommand(appid, command.Application_Id, userId, BuiltIns.DefineCommandCommand.Id, BuiltIns.AllRole.Id);
         modelAccesser.Add(command);
         return command;
     }
     catch (Exception)
     {
         throw new DatabaseException();
     }
 }
Beispiel #7
0
 public void DeleteCommand(int appid, int userId, string token, int id)
 {
     try
     {
         CheckToken(appid, userId, token);
         Command cmd = new Command { Id = id };
         modelAccesser.Get<Command>(cmd);
         if (cmd.Loaded)
         {
             CheckCommand(appid, cmd.Application_Id, userId, BuiltIns.DefineCommandCommand.Id, BuiltIns.AllRole.Id);
             modelAccesser.Delete(cmd);
         }
     }
     catch (Exception)
     {
         throw new DatabaseException();
     }
 }
 public YoYoStudio.Model.Core.Command AddCommand(int userId, string token, YoYoStudio.Model.Core.Command command)
 {
     return(client.AddCommand(application_Id, userId, token, command));
 }
 public void UpdateCommand(int userId, string token, YoYoStudio.Model.Core.Command command)
 {
     client.UpdateCommand(application_Id, userId, token, command);
 }
 public CommandViewModel(Command cmd, RoomWindowViewModel owner, Action<SecureCommandArgs> execute)
     : this(cmd, owner, execute, null)
 {
 }
 public CommandViewModel(Command cmd,Action<SecureCommandArgs> execute):this(cmd,null,execute)
 {
     
 }
 public CommandViewModel(Command cmd)
     : this(cmd, null)
 {
 }
Beispiel #13
0
 public RoleCommandView(RoleCommand rc, Command cmd)
 {
     roleCommand = rc;
     if (roleCommand != null)
     {
         Id = roleCommand.Id;
         Command_Id = roleCommand.Command_Id;
         IsBuiltIn = roleCommand.IsBuiltIn;
         IsManagerCommand = roleCommand.IsManagerCommand;
         SourceRole_Id = roleCommand.SourceRole_Id;
         TargetRole_Id = roleCommand.TargetRole_Id;
     }
     if (cmd != null && Command_Id == cmd.Id)
     {
         Command_Name = cmd.Name;
         Application_Id = cmd.Application_Id;
         CommandType = cmd.CommandType;
         Money = cmd.Money;
     }
 }