public void Save(IScheduledResource resource, string userName, string password)
        {
            if (!_securityWrapper.IsWindowsAuthorised(Sebatchlogonright, userName))
            {
                throw new SecurityException(
                          @"This task requires that the user account specified has 'Log On As Batch' job rights. 
Please contact your Windows System Administrator.");
            }
            if (!_securityWrapper.IsWarewolfAuthorised(Sebatchlogonright, userName, resource.ResourceId.ToString()))
            {
                throw new SecurityException(
                          String.Format(@"This Workflow requires that you have Execute permission on the '{0}' Workflow. 
Please contact your Warewolf System Administrator.", resource.WorkflowName));
            }
            if (resource.Name.Any(a => "\\/:*?\"<>|".Contains(a)))
            {
                throw new Exception("The task name may not contain the following characters \\/:*?\"<>| .");
            }
            var folder  = TaskService.GetFolder(WarewolfFolderPath);
            var created = CreateNewTask(resource);

            created.Settings.Enabled = resource.Status == SchedulerStatus.Enabled;

            folder.RegisterTaskDefinition(resource.Name, created, TaskCreation.CreateOrUpdate, userName, password,
                                          TaskLogonType.InteractiveTokenOrPassword);
        }
Exemple #2
0
        public void Save(IScheduledResource resource, string userName, string password)
        {
            if (!_securityWrapper.IsWindowsAuthorised(Sebatchlogonright, userName))
            {
                throw new SecurityException(Warewolf.Studio.Resources.Languages.Core.SchedulerLogOnAsBatchError);
            }
            if (!_securityWrapper.IsWarewolfAuthorised(Sebatchlogonright, userName, resource.ResourceId.ToString()))
            {
                throw new SecurityException(String.Format(Warewolf.Studio.Resources.Languages.Core.SchedulerExecutePermissionError, resource.WorkflowName));
            }
            if (resource.Name.Any(a => "\\/:*?\"<>|".Contains(a)))
            {
                throw new Exception(Warewolf.Studio.Resources.Languages.Core.SchedulerInvalidCharactersError + " \\/:*?\"<>| .");
            }
            var folder  = TaskService.GetFolder(WarewolfFolderPath);
            var created = CreateNewTask(resource);

            created.Settings.Enabled = resource.Status == SchedulerStatus.Enabled;
            folder.RegisterTaskDefinition(resource.Name, created, TaskCreation.CreateOrUpdate, userName, password, TaskLogonType.InteractiveTokenOrPassword);
        }