Example #1
0
        public void Delete(int taskId)
        {
            DBEntities e   = COREobject.i.Context;
            Task       row = e.Tasks.Single(m => m.Id == taskId);

            ICortexAPI api = GetAPI();

            api.Delete(row);

            e.Tasks.Remove(row);
            e.SaveChanges();
        }
Example #2
0
        public int?Save(Task model)
        {
            DBEntities e        = COREobject.i.Context;
            Task       row      = !model.Id.Equals(null) ? e.Tasks.Single(m => m.Id == model.Id) : new Task();
            Task       original = !model.Id.Equals(null) ? e.Tasks.Single(m => m.Id == model.Id) : null;

            row.Active               = model.Active;
            row.AppId                = model.AppId;
            row.Daily_Repeat         = model.Daily_Repeat;
            row.Duration             = model.Duration;
            row.End_Date             = model.End_Date;
            row.End_Time             = model.End_Time;
            row.Repeat               = model.Repeat;
            row.Repeat_Minute        = model.Repeat_Minute;
            row.Repeat_Duration      = model.Repeat_Duration;
            row.Idle_Time            = model.Idle_Time;
            row.Monthly_Days         = GetDaysInMonthFlags();
            row.Monthly_In_Days      = GetDaysFlags("Monthly_In_Days[]");
            row.Monthly_In_Modifiers = GetModifierFlags();
            row.Monthly_Months       = GetMonthsFlags();
            row.Monthly_Type         = model.Monthly_Type;
            row.Name          = model.Name;
            row.Start_Date    = model.Start_Date;
            row.Start_Time    = model.Start_Time;
            row.Type          = model.Type;
            row.Url           = model.Url;
            row.Weekly_Days   = GetDaysFlags("Weekly_Days[]");
            row.Weekly_Repeat = model.Weekly_Repeat;

            ICortexAPI api = GetAPI();

            if (model.Id.Equals(null))
            {
                e.Tasks.Add(row);
                e.SaveChanges();
                api.Create(row);
            }
            else
            {
                api.Change(row, original);
            }

            e.SaveChanges();
            return(row.Id);
        }
Example #3
0
        public void ClearObsolateOneTimeTasks()
        {
            DateTime now     = DateTime.UtcNow;
            DateTime oldDate = now.AddMinutes(-10);
            TimeSpan oldTime = new TimeSpan(oldDate.Hour, oldDate.Minute, oldDate.Second);

            oldDate = oldDate.AddHours(-oldDate.Hour);
            oldDate = oldDate.AddMinutes(-oldDate.Minute);
            oldDate = oldDate.AddSeconds(-oldDate.Second);

            ICortexAPI  api      = GetAPI();
            List <Task> taskList = COREobject.i.Context.Tasks.Where(t => t.Type == ScheduleType.ONCE).ToList();

            List <Task> taskForDelete = new List <Task>();

            foreach (Task t in taskList)
            {
                if (t.Start_Date < oldDate)
                {
                    taskForDelete.Add(t);
                }
                if (t.Start_Date == oldDate && t.Start_Time <= oldTime)
                {
                    taskForDelete.Add(t);
                }
            }

            if (taskForDelete.Count > 0)
            {
                foreach (Task t in taskForDelete)
                {
                    api.Delete(t);
                }
                COREobject.i.Context.Tasks.RemoveRange(taskForDelete);
            }
        }
Example #4
0
        public string List()
        {
            ICortexAPI api = GetAPI();

            return(api.List());
        }
Example #5
0
        public void Delete(string taskName)
        {
            ICortexAPI api = GetAPI();

            api.Delete(taskName);
        }