Exemple #1
0
        public RCProcessScheduler Clone()
        {
            RCProcessScheduler rcprocessScheduler = new RCProcessScheduler();

            rcprocessScheduler.SetFromVariable(this.Name, this.ScheduleType, this.ScheduleTime, this.ExeType, this.Command, this.Enabled);
            return(rcprocessScheduler);
        }
Exemple #2
0
 public void Modify(RCProcessScheduler newSchedule)
 {
     if (this.Name != newSchedule.Name)
     {
         throw new ArgumentException("Name must be same when modifying properties!");
     }
     this.SetFromVariable(newSchedule.Name, newSchedule.ScheduleType, newSchedule.ScheduleTime, newSchedule.ExeType, newSchedule.Command, newSchedule.Enabled);
 }
Exemple #3
0
        private void RunExe(RCProcess process)
        {
            switch (ExeType)
            {
            case RCProcessScheduler.EExeType.StdInput:
                break;

            case RCProcessScheduler.EExeType.ExternalExe:
            {
                string[] commands = RCProcessScheduler.ParseExternalCommand(Command);
                if (commands == null || commands.Length <= 0)
                {
                    return;
                }
                string workDir  = Path.GetDirectoryName(commands[0]);
                string fileName = Path.GetFileName(commands[0]);
                if (!Path.IsPathRooted(workDir))
                {
                    workDir = BaseConfiguration.WorkingDirectory + "\\" + workDir;
                }
                if (string.IsNullOrEmpty(workDir))
                {
                    workDir = BaseConfiguration.WorkingDirectory;
                }
                ProcessStartInfo startInfo = new ProcessStartInfo();
                startInfo.WorkingDirectory = workDir;
                StringBuilder sb = new StringBuilder();
                for (int i = 1; i < commands.Length; i++)
                {
                    sb.AppendFormat("\"{0}\" ", commands[i]);
                }
                RCProcess.MakeProcess(startInfo, fileName, sb.ToString());
                Process proc = new Process();
                proc.StartInfo = startInfo;
                try
                {
                    proc.Start();
                    return;
                }
                catch (Exception ex)
                {
                    Log <RCClient> .Logger.ErrorFormat("[{0}] - Exception in Start Schedule - {1}", process.Name, Name);

                    process.AddLogManual("Exception in Start() - " + ex.Message);
                    return;
                }
            }

            default:
                return;
            }
            process.StandardIn(Command);
        }
Exemple #4
0
        private static string[] ParseExternalCommand(string commandline)
        {
            int    num    = 0;
            IntPtr intPtr = RCProcessScheduler.CommandLineToArgvW(commandline, out num);

            string[] result;
            try
            {
                string[] array = new string[num];
                int      num2  = 0;
                for (int i = 0; i < num; i++)
                {
                    IntPtr ptr = Marshal.ReadIntPtr(intPtr, num2);
                    num2    += IntPtr.Size;
                    array[i] = Marshal.PtrToStringUni(ptr);
                }
                result = array;
            }
            finally
            {
                RCProcessScheduler.LocalFree(intPtr);
            }
            return(result);
        }