Ejemplo n.º 1
0
        /// <summary>
        /// Execute a command
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>

        public static string Execute(string command, string commandArgs)
        {
            if (ServiceFacade.UseRemoteServices)
            {
                ScheduledTaskTypes taskType =                 // get type of scheduled task
                                              (ScheduledTaskTypes)Enum.Parse(typeof(ScheduledTaskTypes), command);

                NativeMethodTransportObject resultObject = ServiceFacade.CallServiceMethod(
                    ServiceCodes.MobiusTaskSchedulerService,
                    MobiusTaskSchedulerService.Execute,
                    new object[] { (int)taskType, commandArgs });

                if (resultObject == null)
                {
                    return(null);
                }

                string        result        = "";
                ScheduledTask scheduledTask = resultObject.Value as ScheduledTask;
                if (scheduledTask == null)
                {
                    throw new Exception("Command failed (null resultObject)");
                }

                else
                {
                    if (scheduledTask.Status == ScheduledTaskStatus.Succeeded)
                    {
                        if (scheduledTask.Result != null)
                        {
                            result = scheduledTask.Result.ToString();
                        }
                    }
                    else
                    {
                        result = scheduledTask.Status.ToString() +
                                 ((scheduledTask.Result == null) ? "" : ": " + scheduledTask.Result.ToString());
                        throw new Exception(result);
                    }
                }
                return(result);
            }

            else
            {
                return(Mobius.ToolServices.CommandLineService.ExecuteCommand(commandArgs));
            }
        }
Ejemplo n.º 2
0
        object IInvokeServiceOps.InvokeServiceOperation(int opCode, object[] args)
        {
            if (_defaultMetaDataDir == null)
            {
                _defaultMetaDataDir = ServicesDirs.MetaDataDir;
            }

            MobiusTaskSchedulerService op = (MobiusTaskSchedulerService)opCode;

            switch (op)
            {
            case MobiusTaskSchedulerService.Execute:
            {
                ScheduledTaskTypes taskType   = (ScheduledTaskTypes)args[0];
                string             commandArg = (string)args[1];
                ScheduledTask      task       = new ScheduledTask(taskType, commandArg);
                object             response   = ExecuteCommand(task);
                return(response);
            }

            case MobiusTaskSchedulerService.SubmitJob:
            {
                ScheduledTaskTypes taskType   = (ScheduledTaskTypes)args[0];
                string             commandArg = (string)args[1];
                ScheduledTask      task       = new ScheduledTask(taskType, commandArg);
                StartJob(task);
                return(task);
            }

            case MobiusTaskSchedulerService.CheckJobStatus:
            {
                int           jobId = (int)args[0];
                ScheduledTask task  = CheckJob(jobId);
                return(task);
            }
            }
            return(null);
        }
Ejemplo n.º 3
0
 public ScheduledTask(ScheduledTaskTypes taskType, string commandArg)
 {
     TaskType   = taskType;
     CommandArg = commandArg;
 }