Example #1
0
        private void Start()
        {
            var startInfo = new ProcessStartInfo
            {
                FileName               = TaskSetup.Executable,
                Arguments              = TaskSetup.GetCmdLineParams(),
                WorkingDirectory       = _workingDir,
                UseShellExecute        = false,
                CreateNoWindow         = true,
                RedirectStandardInput  = true,
                RedirectStandardOutput = true,
                RedirectStandardError  = true
            };

            using (var process = new Process())
            {
                process.StartInfo           = startInfo;
                process.ErrorDataReceived  += new DataReceivedEventHandler(OnErrorDataReceived);
                process.OutputDataReceived += new DataReceivedEventHandler(OnOutputDataReceived);
                process.Start();
                process.BeginErrorReadLine();
                process.BeginOutputReadLine();
                process.WaitForExit();
                IsFinished = true;
                if (TaskFinishedCallback == null)
                {
                    return;
                }
                TaskFinishedCallback();
            }
        }
Example #2
0
 public OfficeTask(TaskSetup setup)
 {
     Id          = Guid.NewGuid();
     TaskSetup   = setup;
     _workingDir = new FileInfo(Assembly.GetEntryAssembly().Location).Directory.FullName;
     _progress   = new OfficeProgress(args => ConvertProgressEvent(this, args));
 }
        public void Convert(TaskSetup setup)
        {
            var task = new OfficeTask(setup);

            task.TaskFinishedCallback += () => TaskFinished(setup);
            task.ConvertFinishedEvent += ConvertFinished;
            task.ConvertProgressEvent += ConvertProgress;
            _queue.EnqueueTask(task);
        }
 public virtual void TaskFinished(TaskSetup setup)
 {
     if (!string.IsNullOrWhiteSpace(setup.Source))
     {
         File.Delete(setup.Source);
     }
     if (setup.CompletedCallBack != null)
     {
         setup.CompletedCallBack(setup);
     }
 }
Example #5
0
 public static bool ProgressCompleted(object sender, ConvertProgressEventArgs eargs, out TaskSetup setup)
 {
     if (eargs.IsCompleted)
     {
         if (sender is OfficeTask)
         {
             setup = (sender as OfficeTask).TaskSetup;
             return(true);
         }
         setup = null;
         return(true);
     }
     setup = null;
     return(false);
 }