Beispiel #1
0
 public static SaveJobResult AskAndExportToFile(Func <Job> createJob)
 {
     return(SaveJobForm.Run(createJob));
     //if (!Registration.TryCheckEdition(SoftwareEdition.Professional, "export to job")) return;
     //string name = InputBox.Run(Texts.Get("s_select_job_name"), "job");
     //if (name != null)
     //{
     //    string fn = Path.Combine(Core.JobsDirectory, name + ".djb");
     //    if (File.Exists(fn))
     //    {
     //        if (MessageBox.Show(Texts.Get("s_file_exists_overwrite$file", "file", fn), "DatAdmin", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
     //    }
     //    try
     //    {
     //        Job job = createJob();
     //        job.SaveToFile(fn);
     //        UsageStats.Usage("export_as_job", "jobname", job.ToString());
     //    }
     //    catch (Exception err)
     //    {
     //        Errors.Report(err);
     //    }
     //}
 }
Beispiel #2
0
        public static SaveJobResult Run(Func <Job> createJob)
        {
            if (!LicenseTool.FeatureAllowedMsg(JobsFeature.Test))
            {
                return(null);
            }
            //if (!Licenseto. Registration.TryCheckEdition(SoftwareEdition.Professional, "export to job")) return null;
            SaveJobForm win = new SaveJobForm();

            if (win.ShowDialogEx() == DialogResult.OK)
            {
                if (win.rbtCreateNewJob.Checked)
                {
                    string fn = Path.Combine(Core.JobsDirectory, win.tbxJob.Text + ".djb");
                    if (File.Exists(fn))
                    {
                        if (!StdDialog.ReallyOverwriteFile(fn))
                        {
                            return(null);
                        }
                    }
                    try
                    {
                        Job job = createJob();
                        job.SaveToFile(fn);
                        if (win.chbAddToFavorites.Checked)
                        {
                            if (String.IsNullOrEmpty(win.addToFavoritesFrame1.FavoriteName))
                            {
                                win.addToFavoritesFrame1.FavoriteName = Path.GetFileNameWithoutExtension(fn);
                            }
                            win.addToFavoritesFrame1.Favorite = new JobFavorite {
                                JobFile = fn
                            };
                            Favorites.AddLast(win.addToFavoritesFrame1.GetHolder());
                            Favorites.NotifyChanged();
                        }
                        //UsageStats.Usage("export_as_job", "jobname", job.ToString(), "addtofavorite", win.chbAddToFavorites.Checked ? "1" : "0");
                        return(new SaveJobResult
                        {
                            Commands = new List <JobCommand>(job.Root.m_commands),
                            JobConn = new JobConnection(fn),
                        });
                    }
                    catch (Exception err)
                    {
                        Errors.Report(err);
                    }
                }
                if (win.rbtAppendToExistingJob.Checked)
                {
                    string fn   = Path.Combine(Core.JobsDirectory, win.lbxJobs.Items[win.lbxJobs.SelectedIndex].ToString());
                    Job    job  = Job.LoadFromFile(fn);
                    Job    job2 = createJob();
                    job.Root.m_commands.AddRange(job2.Root.m_commands);
                    job.SaveToFile(fn);
                    return(new SaveJobResult
                    {
                        Commands = new List <JobCommand>(job2.Root.m_commands),
                        JobConn = new JobConnection(fn),
                    });
                }
            }
            return(null);
        }