Example #1
0
 public JobModel(JobConsole.Model.JobInfo data)
 {
     this.Active = data.Active;
     this.ClassName = data.ClassName;
     this.ID = data.ID;
     this.Name = data.Name;
     this.Description = data.Description;
     this.Status = data.Status;
     this.StartType = data.StartType;
     this.Trigger = data.Trigger;
 }
Example #2
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;
        }
Example #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;
        }