Esempio n. 1
0
        public bool CreateSchedule(Schedule obj)
        {
            try
            {
                using (var ctx = new ZzaDbContext())
                {

                    var query = ctx.Tasks.FirstOrDefault(x => x.taskID == obj.taskID);

                    if (query != null)
                    {
                        query.Status = "Queued";
                        query.OutputLog = string.Empty;

                        ctx.SaveChanges();
                    }
                    var q = ctx.Schedules.Add(obj);
                    ctx.SaveChanges();
                }
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
Esempio n. 2
0
 public bool CreateTask(Task obj)
 {
     try
     {
         using (var ctx = new ZzaDbContext())
         {
             var q = ctx.Tasks.Add(obj);
             ctx.SaveChanges();
         }
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
Esempio n. 3
0
        public bool DeleteClient(int id)
        {
            try
            {
                using (var ctx = new ZzaDbContext())
                {
                    var tasks = ctx.Tasks.Where(x => x.ClientID == id).ToList();

                    if (tasks.Any())
                    {
                        foreach (var tsk in tasks)
                        {
                            ctx.Tasks.Remove(tsk);
                            ctx.SaveChanges();
                        }
                    }

                    var client = ctx.Clients.First(m => m.ID == id);
                    ctx.Clients.Remove(client);
                    ctx.SaveChanges();
                    return true;
                }
            }
            catch (Exception)
            {

                return false;
            }
        }
Esempio n. 4
0
 public bool UpdateTaskInformation(Task obj)
 {
     try
     {
         using (var ctx = new ZzaDbContext())
         {
             var q = ctx.Tasks.First(m => m.taskID == obj.taskID);
             if (q != null)
             {
                 q.Command = obj.Command;
                 q.Path = obj.Path;
                 q.TaskName = obj.TaskName;
                 q.TaskType = obj.TaskType;
                 q.Status = "Queued";
                 q.OutputLog = string.Empty;
                 ctx.SaveChanges();
             }
         }
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
Esempio n. 5
0
        public bool UpdateScheduleInformation(Schedule obj)
        {
            try
            {
                using (var ctx = new ZzaDbContext())
                {
                    var query = ctx.Tasks.FirstOrDefault(x => x.taskID == obj.taskID);

                    if (query != null)
                    {
                        query.Status = "Queued";
                        query.OutputLog = string.Empty;

                        ctx.SaveChanges();
                    }

                    var q = ctx.Schedules.First(m => m.sID == obj.sID);
                    if (q != null)
                    {
                        q.endAt = obj.endAt;
                        q.startAt = obj.startAt;
                        q.intHours = obj.intHours;
                        q.intMin = obj.intMin;
                        q.intSec = obj.intSec;
                        q.repeatforever = obj.repeatforever;
                        ctx.SaveChanges();
                    }
                }
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
Esempio n. 6
0
 public bool UpdateClientInformation(Client obj)
 {
     try
     {
         using (var ctx = new ZzaDbContext())
         {
             var q = ctx.Clients.First(m => m.ID == obj.ID);
             if (q != null)
             {
                 q.HostName = obj.HostName;
                 q.IpAddress = obj.IpAddress;
                 q.Username = obj.Username;
                 q.Password = obj.Password;
                 ctx.SaveChanges();
             }
         }
         return true;
     }
     catch (Exception)
     {
         return false;
     }
 }
Esempio n. 7
0
        public void TaskDone(int taskid, string output)
        {
            try
            {
                using (var ctx = new ZzaDbContext())
                {
                    var q = ctx.Tasks.First(m => m.taskID == taskid);
                    q.Status = "Done";
                    q.OutputLog = output;
                    ctx.SaveChanges();
                }
            }
            catch (Exception)
            {

            }
        }
Esempio n. 8
0
        public bool DeleteTask(int taskid)
        {
            try
            {
                using (var ctx = new ZzaDbContext())
                {
                    var task = ctx.Tasks.FirstOrDefault(x => x.taskID == taskid);
                    if (task != null)
                    {
                        ctx.Tasks.Remove(task);
                        ctx.SaveChanges();
                    }

                    return true;
                }
            }
            catch (Exception)
            {

                return false;
            }
        }