private IEnumerable <CommandExecutionStatus> GetErrorExecutionStatuses(IMassCommand arg) { return(arg.InstanceIds.Select( p => new CommandExecutionStatus { InstanceId = p, Result = CommandExecutionResult.Error })); }
private IEnumerable <CommandExecutionStatus> ExecuteMassCommand(IMassCommand arg) { var states = new MultiThreadedPersistance <CommandExecutionStatus>(); var handles = new List <WaitHandle>(); foreach (var instanceId in arg.InstanceIds) { var handle = new AutoResetEvent(false); handles.Add(handle); var state = new MultipleExportState { InstanceId = instanceId, States = states, WaitHandle = handle, AuthorizationService = AuthorizationService, Identity = AuthenticationService.GetCurrentIdentity(), Comment = arg.Comment, CommandToExecute = arg.Command, StateToSet = (arg is IContainsStateName) ? (arg as IContainsStateName).StateNameToSet : null }; ThreadPool.QueueUserWorkItem(RaiseCommandTask, state); } WaitHandle.WaitAll(handles.ToArray(), new TimeSpan(0, 0, 10, 0)); return(states.Items); }