public BackupSchedule(BackupSchedule schedule)
        {
            _Repeat = schedule._Repeat;
            _Time   = schedule._Time;
            DateTime RealTime = DateTime.Today + schedule._Time.TimeOfDay;

            _Time = RealTime;
            if (_Repeat) // nếu cho phép repeat thì thêm các công việc cho từng ngày
            {
                _Thu = schedule._Thu;

                /// i chạy từ ngày hiện hành
                /// j là số ngày cần phải cộng thêm vào
                for (int i = (int)DateTime.Now.DayOfWeek, j = 0; j < 7; i++, j++)
                {
                    int Sttthu = i < 7 ? i : i - 7;
                    if (_Thu[Sttthu])
                    {
                        Works[Sttthu] = WorkExcuter.WorksManager.GetNewWork(RealTime.AddDays(j),
                                                                            new WorkExcuter.CallBackDlg(CallBack), new WorkExcuter.CallBackDlg(OnNotExcuted), RealTime, false).WorkID;
                    }
                }
            }
            else
            {
                if (RealTime.CompareTo(DateTime.Now) < 0) // Realtime đã trôi qua
                {
                    RealTime = RealTime.AddDays(1);
                    _Time    = RealTime;
                }
                NoRepeatWork = WorkExcuter.WorksManager.GetNewWork(RealTime, new WorkExcuter.CallBackDlg(CallBack), new WorkExcuter.CallBackDlg(OnNotExcuted), RealTime, false).WorkID;
            }
        }
 public void Addschedule(BackupSchedule Schedule)
 {
     App.Current.Dispatcher.Invoke((Action) delegate
     {
         BackupSchedules.Add(Schedule);
         Save();
     });
 }
 private void RemoveBackupSchedule(BackupSchedule schedule)
 {
     /// Code remove này đang thay đổi một ObservalueCollection
     /// nhưng loại collection này chỉ được thay đổi ở thread mà nó được tạo
     /// Vậy ta phải dùng dispatcher để gọi code này
     App.Current.Dispatcher.Invoke((Action) delegate
     {
         _BackupSchedules.Remove(schedule);
         Save();
     });
 }
 /// <summary>
 /// Hàm này sẽ kiểm tra và sửa các lỗi có thể có khi lưu file xuống trong phiên làm việc trước
 /// Hàm này chỉ được gọi khi Package WorkExcuter đã Initialize
 /// </summary>
 /// <returns></returns>
 public void CheckAndFixError()
 {
     foreach (var item in BackupSchedules)
     {
         if (item.IsError()) // nếu bị lỗi thì terminate xóa nó đi
         {
             item.Terminate();
             BackupSchedule newschedule = new BackupSchedule(item);
             Addschedule(newschedule);
         }
     }
 }