Пример #1
0
        public IdleTasks GetState()
        {
            IdleTasks idleTasks = new IdleTasks();

            try
            {
                var content    = File.ReadAllLines("IdlerState.json");
                var jsonObject = JsonConvert.DeserializeObject <IdleTasks>(content[0]);
                foreach (var task in jsonObject)
                {
                    idleTasks.Add(new IdleTask()
                    {
                        Name         = task.Name,
                        EndDay       = task.EndDay,
                        EndHour      = task.EndHour,
                        EndMinutes   = task.EndMinutes,
                        StartDay     = task.StartDay,
                        StartHour    = task.StartHour,
                        StartMinutes = task.StartMinutes,
                        StartMonth   = task.StartMonth,
                        StartYear    = task.StartYear
                    });
                }
            }
            catch (FileNotFoundException)
            {
            }

            return(idleTasks);
        }
Пример #2
0
        private void PutState(NotificationMessage message)
        {
            IdleTasks tasks = new IdleTasks();

            foreach (var task in Tasks)
            {
                tasks.Add(new IdleTask()
                {
                    Name         = task.Name,
                    StartDay     = task.DateTimeStart.Day,
                    StartHour    = task.DateTimeStart.Hour,
                    StartMinutes = task.DateTimeStart.Minute,
                    StartMonth   = task.DateTimeStart.Month,
                    EndHour      = task.TSpan.Hours,
                    EndDay       = task.TSpan.Days,
                    EndMinutes   = task.TSpan.Minutes,
                    Status       = task.Status,
                    StatusText   = Enums.Status.Run.ToString()
                });
            }
            this.serializer.SaveState(tasks);
        }