Ejemplo n.º 1
0
        public void CreateNewJob(string jobname)
        {
            //check if already exists.
            using (var context = new JobContext())
            {
                try
                {
                    var job = context.Jobs.First(j => j.name == jobname);
                    if (job != null)
                    {
                        Debug.WriteLine(jobname + "はすでにテーブルに存在しているため追加しませんでした。");
                        return;
                    }
                }
                catch
                {
                }

            }

            Job newjob = new Job(jobname);
            using (var context = new JobContext())
            {

                context.Jobs.Add(newjob);
                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
 public string currentWorkingTime(string jobname)
 {
     using (var context = new JobContext())
     {
         var job = context.Jobs.First(j => j.name == jobname);
         TimeSpan time = job.currentWorkingTime(DateTime.Now);
         return TimeHelper.Timespan2String(time);
     }
 }
Ejemplo n.º 3
0
        public void DeleteJob(string jobname)
        {
            using (var context = new JobContext())
            {
                var job = context.Jobs.First(j => j.name == jobname);
                context.Jobs.Remove(job);

                context.SaveChanges();
            }
        }
Ejemplo n.º 4
0
 public List<JobRecord> GetAllJobRecords()
 {
     try
     {
         using (var context = new JobContext())
         {
             var records = from record in context.JobRecords
                           select record;
             return records.ToList();
         }
     }
     catch
     {
         return null;
     }
 }
Ejemplo n.º 5
0
 public List<JobRecord> GetAllRecordAboutJob(string jobname)
 {
     try
     {
         using (var context = new JobContext())
         {
             var records = from record in context.JobRecords
                           where record.name == jobname
                           select record;
             return records.ToList();
         }
     }
     catch
     {
         return null;
     }
 }
Ejemplo n.º 6
0
        public List<string> GetJobList()
        {
            List<string> joblist = new List<string>();

            using (var context = new JobContext())
            {
                foreach (var job in context.Jobs)
                {
                    joblist.Add(job.name);
                }
            }

            return joblist;
        }
Ejemplo n.º 7
0
        public string totalWorkingTime(string jobname)
        {
            using (var context = new JobContext())
            {
                var job = context.Jobs.First(j => j.name == jobname);

                TimeSpan time = TimeHelper.String2Timespan(job.totalWorkingTime);
                if (job.isRunning)
                    time = time.Add(job.currentWorkingTime(DateTime.Now));
                return TimeHelper.Timespan2String(time);
            }
        }
Ejemplo n.º 8
0
        public void StopJob(string jobname)
        {
            using (var context = new JobContext())
            {
                var job = context.Jobs.First(j => j.name == jobname);
                DateTime now = DateTime.Now;
                job.stop(now);

                JobRecord record = new JobRecord(job);
                context.JobRecords.Add(record);

                context.SaveChanges();
            }
        }
Ejemplo n.º 9
0
 public void StartJob(string jobname)
 {
     using (var context = new JobContext())
     {
         var job = context.Jobs.First(j => j.name == jobname);
         job.start(DateTime.Now);
         context.SaveChanges();
     }
 }
Ejemplo n.º 10
0
        public bool IsThereJob(string jobname)
        {
            using (var context = new JobContext())
            {
                Job job = null;
                try
                {
                    job = context.Jobs.First(j => j.name == jobname);
                }
                catch { }

                if (job != null)
                    return true;
                else
                    return false;
            }
        }
Ejemplo n.º 11
0
        public bool IsRunningJob(string jobname)
        {
            using (var context = new JobContext())
            {
                try
                {
                    var job = context.Jobs.First(j => j.name == jobname);
                    return job.isRunning;
                }
                catch
                {
                    return false;
                }

            }
        }