Exemple #1
0
        public bool AddJob(string name, string description, bool active, StartType startType, string className, JobConsole.Model.Trigger trigger, out string message)
        {
            var dao = new Data.JobDAO();

            string triggerJson = Newtonsoft.Json.JsonConvert.SerializeObject(trigger);

            Guid? id;
            bool success = dao.Add(name, description, active, startType, triggerJson, className, out message, out id);

            if (success)
            {
                Task.Factory.StartNew(() =>
                {
                    var data = dao.Get(id.Value);
                    var job = new JobItem(data);
                    this.Jobs.Add(job);
                    job.NotifyJobModified();
                });
            }

            return success;
        }
Exemple #2
0
 private void LoadJobs()
 {
     var dao = new Data.JobDAO();
     this.Jobs = dao.All().Select(t => new JobItem(t)).ToList();
 }
Exemple #3
0
        public bool Edit(string description, bool active, StartType startType, JobConsole.Model.Trigger trigger, string className, out string message)
        {
            if (this.Status == JobStatus.Running)
            {
                message = "Job正在运行";
                return false;
            }

            string triggerJson = Newtonsoft.Json.JsonConvert.SerializeObject(trigger);

            var dao = new Data.JobDAO();
            bool success = dao.Edit(this.ID, description, active, startType, triggerJson, className, out message);

            if (success)
            {
                var data = dao.Get(this.ID);
                this.Data = data;

                XDocument doc = new XDocument();
                doc.Add(
                    new XElement("Job",
                        new XElement("ClassName", this.Data.ClassName)
                    )
                );
                doc.Save(this.JobFolder + @"\" + "job.config");

                this.NotifyJobModified();
            }

            return success;
        }