예제 #1
0
        private void btnRunJob_Click(object sender, EventArgs e)
        {
            if (lsvJobs.SelectedItems.Count == 0)
            {
                return;
            }
            if (MessageBox.Show(Texts.Get("s_really_run$jobs", "jobs", lsvJobs.SelectedItems.Count), VersionInfo.ProgramTitle, MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }
            var cmdlist = new List <JobCommand>();
            var joblist = new List <string>();
            var job     = new Job();

            foreach (ListViewItem item in lsvJobs.SelectedItems)
            {
                var rec = (JobWithFile)item.Tag;
                joblist.Add(rec.Job.ToString());
                // we must load current version of job
                var job2 = Job.LoadFromFile(rec.FullFile);
                foreach (var cmd in rec.Job.Root.Commands)
                {
                    var find = job2.FindCommand(cmd.GroupId);
                    if (find != null)
                    {
                        job.AddCommand(find.Clone(false));
                    }
                    else
                    {
                        job.AddCommand(cmd.Clone(false));
                    }
                }
                job.Root.ReportConfigs.AddRange(job2.Root.ReportConfigs);
            }
            job.Title = joblist.CreateDelimitedText(";");
            job.CreateProcess(new Dictionary <string, string>()).Start();
        }