OSDN Git Service

Ver.1.0.0.185 Task187 Interface based design
[simplebackup/SBTGitRepository.git] / Main / SimpleBackup.Services / BackupService.cs
1 //-----------------------------------------------------------------------
2 // <copyright file="BackupService.cs" company="Takayoshi Matsuyama">
3 //     Copyright (c) Takayoshi Matsuyama. All rights reserved.
4 // </copyright>
5 //-----------------------------------------------------------------------
6
7 // This file is part of Simple Backup.
8 //
9 // Simple Backup is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // Simple Backup is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with Simple Backup.  If not, see <http://www.gnu.org/licenses/>.
21
22 namespace SimpleBackup.Services
23 {
24     using System;
25     using System.Collections.Generic;
26     using System.IO;
27     using System.IO.Compression;
28     using System.Linq;
29     using System.Text;
30     using System.Text.RegularExpressions;
31     using System.Threading;
32     using SimpleBackup.Core;
33     using SimpleBackup.Core.Models;
34     using SimpleBackup.Core.Services;
35     using SimpleBackup.Core.Utilities;
36     using SimpleBackup.Resources;
37
38     /// <summary>
39     /// Backup service.
40     /// </summary>
41     internal class BackupService : IBackupService
42     {
43         /// <summary>
44         /// The synchronize root
45         /// </summary>
46         private static readonly object SyncRoot = new object();
47
48         /// <summary>
49         /// The instance of BackupService.
50         /// </summary>
51         private static volatile BackupService instance;
52
53         /// <summary>
54         /// Prevents a default instance of the <see cref="BackupService"/> class from being created.
55         /// </summary>
56         private BackupService()
57         {
58             BackupSettingService.Instance.BackupSettingCreated += this.OnBackupSettingCreated;
59             BackupSettingService.Instance.BackupSettingOpened += this.OnBackupSettingOpened;
60             BackupSettingService.Instance.BackupSettingClosed += this.OnBackupSettingClosed;
61         }
62
63         /// <summary>
64         /// Occurs when file backup progress is updated.
65         /// </summary>
66         public event EventHandler<FileBackupProgressEventArgs> NofityFileBackupProgress;
67
68         /// <summary>
69         /// Gets the instance.
70         /// </summary>
71         public static IBackupService Instance
72         {
73             get
74             {
75                 if (instance == null)
76                 {
77                     lock (SyncRoot)
78                     {
79                         if (instance == null)
80                         {
81                             instance = new BackupService();
82                         }
83                     }
84                 }
85
86                 return instance;
87             }
88         }
89
90         /// <summary>
91         /// Gets a value indicating whether this service is ready for backup.
92         /// </summary>
93         public bool IsReadyForBackup { get; private set; }
94
95         /// <summary>
96         /// Gets a value indicating whether this service is executing backup.
97         /// </summary>
98         public bool IsExecutingBackup { get; private set; }
99
100         /// <summary>
101         /// Backups multipul files.
102         /// </summary>
103         /// <param name="cancellationToken">The cancellation token.</param>
104         /// <param name="resultInfos">The array of result information.</param>
105         public void BackupMultipulFiles(CancellationToken cancellationToken, out IResultInfo[] resultInfos)
106         {
107             var modelFactory = ObjectContainer.Resolve<IModelFactory>();
108
109             this.IsExecutingBackup = true;
110             var resultList = new List<IResultInfo>();
111             if (this.IsReadyForBackup == false)
112             {
113                 resultList.Add(modelFactory.CreateResultInfo(BackupState.Failed, Resources.Backup_Failed_BackupInfomationNotPrepared));
114                 resultInfos = resultList.ToArray();
115                 return;
116             }
117
118             try
119             {
120                 this.NotifyBackupProgress(0, null);
121                 
122                 int processedCount = 0;
123
124                 foreach (IBackupInfo backupInfo in BackupSettingService.Instance.CurrentSetting.BackupInfos)
125                 {
126                     cancellationToken.ThrowIfCancellationRequested();
127                     backupInfo.BackupState = BackupState.InProgress;
128
129                     Thread.Sleep(100);
130
131                     IResultInfo resultInfo = null;
132                     double progressValue = 0;
133
134                     if (backupInfo.IsEnabled == false)
135                     {
136                         string description = string.Format(
137                             "{0}\r\n\t{1}: {2}",
138                             Resources.Backup_Skipped,
139                             Resources.Backup_From,
140                             backupInfo.SourcePath);
141                         resultInfo = modelFactory.CreateResultInfo(BackupState.Skipped, description);
142                         processedCount++;
143                         progressValue = processedCount * 100.0 / BackupSettingService.Instance.CurrentSetting.Count;
144                         this.NotifyBackupProgress(progressValue, resultInfo);
145                         backupInfo.BackupState = BackupState.Skipped;
146                         continue;
147                     }
148
149                     // Check the source.
150                     if (((backupInfo.BackupSourceType == BackupSourceType.File) && (File.Exists(backupInfo.SourcePath) == false)) ||
151                         ((backupInfo.BackupSourceType == BackupSourceType.Folder) && (Directory.Exists(backupInfo.SourcePath) == false)))
152                     {
153                         string description = string.Format(
154                             "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}",
155                             Resources.Backup_Failed_SourceNotExist,
156                             Resources.Backup_From,
157                             backupInfo.SourcePath,
158                             Resources.Backup_To,
159                             backupInfo.DestinationFolderPath);
160                         resultInfo = modelFactory.CreateResultInfo(BackupState.Failed, description);
161                         resultList.Add(resultInfo);
162                         processedCount++;
163                         progressValue = processedCount * 100.0 / BackupSettingService.Instance.CurrentSetting.Count;
164                         this.NotifyBackupProgress(progressValue, resultInfo);
165                         backupInfo.BackupState = BackupState.Failed;
166                         continue;
167                     }
168
169                     // Check the destination.
170                     if ((backupInfo.DestinationFolderPath == "\\") ||
171                         (Directory.Exists(backupInfo.DestinationFolderPath) == false))
172                     {
173                         string description = string.Format(
174                             "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}",
175                             Resources.Backup_Failed_DestinationNotExist,
176                             Resources.Backup_From,
177                             backupInfo.SourcePath,
178                             Resources.Backup_To,
179                             backupInfo.DestinationFolderPath);
180                         resultInfo = modelFactory.CreateResultInfo(BackupState.Failed, description);
181                         resultList.Add(resultInfo);
182                         processedCount++;
183                         progressValue = processedCount * 100.0 / BackupSettingService.Instance.CurrentSetting.Count;
184                         this.NotifyBackupProgress(progressValue, resultInfo);
185                         backupInfo.BackupState = BackupState.Failed;
186                         continue;
187                     }
188
189                     var destinationFileNames = new IDestinationPathInfo[0];
190                     try
191                     {
192                         if (backupInfo.IsZipArchive)
193                         {
194                             if (backupInfo.BackupSourceType == BackupSourceType.File)
195                             {
196                                 BackupFileToZip(backupInfo, out destinationFileNames);
197                             }
198                             else if (backupInfo.BackupSourceType == BackupSourceType.Folder)
199                             {
200                                 BackupFolerToZip(backupInfo, out destinationFileNames);
201                             }
202                         }
203                         else
204                         {
205                             if (backupInfo.BackupSourceType == BackupSourceType.File)
206                             {
207                                 BackupFile(backupInfo, out destinationFileNames);
208                             }
209                             else if (backupInfo.BackupSourceType == BackupSourceType.Folder)
210                             {
211                                 BackupFolder(backupInfo, out destinationFileNames);
212                             }
213                         }
214                     }
215                     catch (Exception e)
216                     {
217                         string description = string.Format(
218                             "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}\r\n{5}",
219                             Resources.Backup_Failed_FailedToCopy,
220                             Resources.Backup_From,
221                             backupInfo.SourcePath,
222                             Resources.Backup_To,
223                             destinationFileNames.FirstOrDefault(),
224                             e.Message);
225                         resultInfo = modelFactory.CreateResultInfo(BackupState.Failed, description);
226                         resultList.Add(resultInfo);
227                         processedCount++;
228                         progressValue = processedCount * 100.0 / BackupSettingService.Instance.CurrentSetting.Count;
229                         this.NotifyBackupProgress(progressValue, resultInfo);
230                         backupInfo.BackupState = BackupState.Failed;
231                         continue;
232                     }
233
234                     if (CheckExistence(destinationFileNames))
235                     {
236                         string description = string.Format(
237                             "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}",
238                             Resources.Backup_Succeeded,
239                             Resources.Backup_From,
240                             backupInfo.SourcePath,
241                             Resources.Backup_To,
242                             destinationFileNames.First().Path);
243                         resultInfo = modelFactory.CreateResultInfo(BackupState.Success, description);
244                         resultList.Add(resultInfo);
245                         backupInfo.BackupState = BackupState.Success;
246                         backupInfo.LatestSuccessfulBackupTargetName = destinationFileNames.First().Path;
247                     }
248
249                     processedCount++;
250                     progressValue = processedCount * 100.0 / BackupSettingService.Instance.CurrentSetting.Count;
251                     this.NotifyBackupProgress(progressValue, resultInfo);
252                 }
253
254                 this.NotifyBackupProgress(100.0, null);
255             }
256             catch (OperationCanceledException)
257             {
258                 var resultInfo = modelFactory.CreateResultInfo(BackupState.Cancelled, Resources.BackupState_Cancelled);
259                 resultList.Add(resultInfo);
260                 this.NotifyBackupProgress(100.0, resultInfo);
261             }
262             finally
263             {
264                 resultInfos = resultList.ToArray();
265                 this.IsExecutingBackup = false;
266             }
267         }
268
269         /// <summary>
270         /// Backups single file.
271         /// </summary>
272         /// <param name="backupInfoId">The backup information identifier.</param>
273         /// <returns>The result information.</returns>
274         public IResultInfo BackupSingleFile(Guid backupInfoId)
275         {
276             var modelFactory = ObjectContainer.Resolve<IModelFactory>();
277
278             IBackupInfo backupInfo = BackupSettingService.Instance.CurrentSetting.FirstOrDefault(backupInfoId);
279             if (backupInfo == null)
280             {
281                 return modelFactory.CreateResultInfo(
282                     BackupState.Failed,
283                     Resources.Backup_Failed_BackupInfomationNotPrepared);
284             }
285
286             backupInfo.BackupState = BackupState.InProgress;
287             Helpers.UpdateWpfGui();
288             
289             IResultInfo resultInfo = null;
290             string description = string.Empty;
291
292             // Check the source.
293             if (((backupInfo.BackupSourceType == BackupSourceType.File) && (File.Exists(backupInfo.SourcePath) == false)) ||
294                 ((backupInfo.BackupSourceType == BackupSourceType.Folder) && (Directory.Exists(backupInfo.SourcePath) == false)))
295             {
296                 description = string.Format(
297                     "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}",
298                     Resources.Backup_Failed_SourceNotExist,
299                     Resources.Backup_From,
300                     backupInfo.SourcePath,
301                     Resources.Backup_To,
302                     backupInfo.DestinationFolderPath);
303                 resultInfo = modelFactory.CreateResultInfo(BackupState.Failed, description);
304                 backupInfo.BackupState = BackupState.Failed;
305                 return resultInfo;
306             }
307
308             // Check the destination.
309             if (Directory.Exists(backupInfo.DestinationFolderPath) == false)
310             {
311                 description = string.Format(
312                     "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}",
313                     Resources.Backup_Failed_DestinationNotExist,
314                     Resources.Backup_From,
315                     backupInfo.SourcePath,
316                     Resources.Backup_To,
317                     backupInfo.DestinationFolderPath);
318                 resultInfo = modelFactory.CreateResultInfo(BackupState.Failed, description);
319                 backupInfo.BackupState = BackupState.Failed;
320                 return resultInfo;
321             }
322
323             var destinationFileNames = new IDestinationPathInfo[0];
324             try
325             {
326                 if (backupInfo.IsZipArchive)
327                 {
328                     if (backupInfo.BackupSourceType == BackupSourceType.File)
329                     {
330                         BackupFileToZip(backupInfo, out destinationFileNames);
331                     }
332                     else if (backupInfo.BackupSourceType == BackupSourceType.Folder)
333                     {
334                         BackupFolerToZip(backupInfo, out destinationFileNames);
335                     }
336                 }
337                 else
338                 {
339                     if (backupInfo.BackupSourceType == BackupSourceType.File)
340                     {
341                         BackupFile(backupInfo, out destinationFileNames);
342                     }
343                     else if (backupInfo.BackupSourceType == BackupSourceType.Folder)
344                     {
345                         BackupFolder(backupInfo, out destinationFileNames);
346                     }
347                 }
348             }
349             catch (Exception e)
350             {
351                 description = string.Format(
352                     "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}\r\n{5}",
353                     Resources.Backup_Failed_FailedToCopy,
354                     Resources.Backup_From,
355                     backupInfo.SourcePath,
356                     Resources.Backup_To,
357                     destinationFileNames.FirstOrDefault(),
358                     e.Message);
359                 resultInfo = modelFactory.CreateResultInfo(BackupState.Failed, description);
360                 backupInfo.BackupState = BackupState.Failed;
361                 return resultInfo;
362             }
363
364             if (CheckExistence(destinationFileNames))
365             {
366                 description = string.Format(
367                     "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}",
368                     Resources.Backup_Succeeded,
369                     Resources.Backup_From,
370                     backupInfo.SourcePath,
371                     Resources.Backup_To,
372                     destinationFileNames.First().Path);
373                 resultInfo = modelFactory.CreateResultInfo(BackupState.Success, description);
374                 backupInfo.BackupState = BackupState.Success;
375                 backupInfo.LatestSuccessfulBackupTargetName = destinationFileNames.First().Path;
376                 return resultInfo;
377             }
378
379             description = string.Format(
380                 "{0}\r\n\t{1}: {2}\r\n\t{3}: {4}",
381                 Resources.Backup_Failed_FailedToCopy,
382                 Resources.Backup_From,
383                 backupInfo.SourcePath,
384                 Resources.Backup_To,
385                 destinationFileNames.FirstOrDefault());
386             return modelFactory.CreateResultInfo(BackupState.Failed, description);
387         }
388
389         private static void BackupFileToZip(IBackupInfo backupInfo, out IDestinationPathInfo[] destinationPathInfoArray)
390         {
391             var innerDestinationPathInfoList = new List<IDestinationPathInfo>();
392
393             var modelFactory = ObjectContainer.Resolve<IModelFactory>();
394
395             Match lastPathSegmentMatch = Constants.EndPathSegmentRegex.Match(backupInfo.SourcePath);
396             Match fileNameMatch = Constants.FileNameRegex.Match(lastPathSegmentMatch.Value);
397             Match extensionMatch = Constants.ExtensionRegex.Match(lastPathSegmentMatch.Value);
398
399             string destinationFolderPath = backupInfo.DestinationFolderPath.AddTailPathSeparatorIfNotExist();
400             string destinationTempFolderPath = destinationFolderPath + fileNameMatch.Value +
401                 " - " + DateTime.Now.ToString("yyyyMMdd-HHmmss") + "-tmp";
402             string destinationTempFileName = destinationTempFolderPath + "\\" + fileNameMatch.Value +
403                 " - " + DateTime.Now.ToString("yyyyMMdd-HHmmss") + "." + extensionMatch.Value;
404             try
405             {
406                 try
407                 {
408                     Directory.CreateDirectory(destinationTempFolderPath);
409                 }
410                 catch (Exception e)
411                 {
412                     throw new InvalidOperationException(
413                         string.Format(
414                             "Failed to create the folder: {0}\r\n{1}",
415                             destinationTempFolderPath,
416                             e.Message),
417                         e);
418                 }
419
420                 try
421                 {
422                     File.Copy(backupInfo.SourcePath, destinationTempFileName);
423                 }
424                 catch (Exception e)
425                 {
426                     throw new InvalidOperationException(
427                         string.Format(
428                             "Failed to copy the file.\r\n\tFrom: {0}\r\n\tTo: {1}\r\n{2}",
429                             backupInfo.SourcePath,
430                             destinationTempFolderPath,
431                             e.Message),
432                         e);
433                 }
434
435                 var destinationFileName = destinationFolderPath + fileNameMatch.Value
436                     + " - " + DateTime.Now.ToString("yyyyMMdd-HHmmss") + ".zip";
437                 innerDestinationPathInfoList.Add(modelFactory.CreateDestinationPathInfo(BackupSourceType.File, destinationFileName));
438
439                 try
440                 {
441                     ZipFile.CreateFromDirectory(
442                         destinationTempFolderPath,
443                         destinationFileName,
444                         CompressionLevel.Optimal,
445                         false,
446                         Encoding.GetEncoding(Properties.Settings.Default.DefaultZipEncodingKeyText));
447                 }
448                 catch (Exception e)
449                 {
450                     backupInfo.BackupState = BackupState.Failed;
451                     throw new InvalidOperationException(
452                         string.Format(
453                             "Failed to create the zip archive.\r\n\tFrom: {0}\r\n\tTo: {1}\r\n{2}",
454                             destinationTempFolderPath,
455                             destinationFileName,
456                             e.Message),
457                         e);
458                 }
459             }
460             finally
461             {
462                 destinationPathInfoArray = innerDestinationPathInfoList.ToArray();
463
464                 if (File.Exists(destinationTempFileName))
465                 {
466                     File.Delete(destinationTempFileName);
467                 }
468
469                 if (Directory.Exists(destinationTempFolderPath))
470                 {
471                     Directory.Delete(destinationTempFolderPath);
472                 }
473             }
474         }
475
476         private static void BackupFolerToZip(IBackupInfo backupInfo, out IDestinationPathInfo[] destinationPathInfoArray)
477         {
478             var innerDestinationPathInfoList = new List<IDestinationPathInfo>();
479
480             var modelFactory = ObjectContainer.Resolve<IModelFactory>();
481
482             Match lastPathSegmentMatch = Constants.EndPathSegmentRegex.Match(backupInfo.SourcePath);
483
484             string destinationFolderPath = backupInfo.DestinationFolderPath.AddTailPathSeparatorIfNotExist();
485             var destinationFileName = destinationFolderPath
486                 + lastPathSegmentMatch.Value + " - "
487                 + DateTime.Now.ToString("yyyyMMdd-HHmmss")
488                 + ".zip";
489             innerDestinationPathInfoList.Add(modelFactory.CreateDestinationPathInfo(BackupSourceType.File, destinationFileName));
490
491             try
492             {
493                 ZipFile.CreateFromDirectory(
494                     backupInfo.SourcePath,
495                     destinationFileName,
496                     CompressionLevel.Optimal,
497                     false,
498                     Encoding.GetEncoding(Properties.Settings.Default.DefaultZipEncodingKeyText));
499             }
500             catch (Exception e)
501             {
502                 backupInfo.BackupState = BackupState.Failed;
503                 throw new InvalidOperationException(
504                     string.Format(
505                         "Failed to create the zip archive.\r\n\tFrom: {0}\r\n\tTo: {1}\r\n{2}",
506                         backupInfo.SourcePath,
507                         destinationFileName,
508                         e.Message),
509                     e);
510             }
511             finally
512             {
513                 destinationPathInfoArray = innerDestinationPathInfoList.ToArray();
514             }
515         }
516
517         private static void BackupFile(IBackupInfo backupInfo, out IDestinationPathInfo[] destinationPathInfoArray)
518         {
519             var innerDestinationPathInfoList = new List<IDestinationPathInfo>();
520
521             var modelFactory = ObjectContainer.Resolve<IModelFactory>();
522
523             Match lastPathSegmentMatch = Constants.EndPathSegmentRegex.Match(backupInfo.SourcePath);
524             Match fileNameMatch = Constants.FileNameRegex.Match(lastPathSegmentMatch.Value);
525             Match extensionMatch = Constants.ExtensionRegex.Match(lastPathSegmentMatch.Value);
526
527             string destinationFolderPath = backupInfo.DestinationFolderPath.AddTailPathSeparatorIfNotExist();
528             var destinationFileName = destinationFolderPath + fileNameMatch.Value
529                 + " - " + DateTime.Now.ToString("yyyyMMdd-HHmmss") + "." + extensionMatch.Value;
530             innerDestinationPathInfoList.Add(modelFactory.CreateDestinationPathInfo(BackupSourceType.File, destinationFileName));
531
532             try
533             {
534                 File.Copy(backupInfo.SourcePath, destinationFileName);
535             }
536             finally
537             {
538                 destinationPathInfoArray = innerDestinationPathInfoList.ToArray();
539             }
540         }
541
542         private static void BackupFolder(IBackupInfo backupInfo, out IDestinationPathInfo[] destinationPathInfoArray)
543         {
544             var innerDestinationPathInfoList = new List<IDestinationPathInfo>();
545
546             var modelFactory = ObjectContainer.Resolve<IModelFactory>();
547
548             Match lastPathSegmentMatch = Constants.EndPathSegmentRegex.Match(backupInfo.SourcePath);
549
550             //// 方法 : ディレクトリをコピーする
551             //// http://msdn.microsoft.com/ja-jp/library/bb762914(v=vs.110).aspx
552             string destinationFolderPath = backupInfo.DestinationFolderPath.AddTailPathSeparatorIfNotExist();
553             var destinationFolderName = destinationFolderPath
554                 + lastPathSegmentMatch.Value + " - " + DateTime.Now.ToString("yyyyMMdd-HHmmss");
555             innerDestinationPathInfoList.Add(modelFactory.CreateDestinationPathInfo(BackupSourceType.Folder, destinationFolderName));
556
557             try
558             {
559                 FolderCopy(backupInfo.SourcePath, destinationFolderName, true);
560             }
561             finally
562             {
563                 destinationPathInfoArray = innerDestinationPathInfoList.ToArray();
564             }
565         }
566
567         private static void FolderCopy(string sourceFolderPath, string destinationFolderPath, bool copySubFolders)
568         {
569             var sourceDirectoryInfo = new DirectoryInfo(sourceFolderPath);
570             DirectoryInfo[] subDirectoryInfos = sourceDirectoryInfo.GetDirectories();
571
572             if (sourceDirectoryInfo.Exists == false)
573             {
574                 throw new DirectoryNotFoundException(
575                     "Source directory does not exist or could not be found: "
576                     + sourceFolderPath);
577             }
578
579             // If the destination directory doesn't exist, create it.
580             if (Directory.Exists(destinationFolderPath) == false)
581             {
582                 Directory.CreateDirectory(destinationFolderPath);
583             }
584
585             // Get the files in the directory and copy them to the new location.
586             FileInfo[] files = sourceDirectoryInfo.GetFiles();
587             foreach (FileInfo file in files)
588             {
589                 string temppath = Path.Combine(destinationFolderPath, file.Name);
590                 file.CopyTo(temppath, false);
591             }
592
593             // If copying subdirectories, copy them and their contents to new location.
594             if (copySubFolders)
595             {
596                 foreach (DirectoryInfo subDirectoryInfo in subDirectoryInfos)
597                 {
598                     string temppath = Path.Combine(destinationFolderPath, subDirectoryInfo.Name);
599                     FolderCopy(subDirectoryInfo.FullName, temppath, copySubFolders);
600                 }
601             }
602         }
603
604         private static bool CheckExistence(IDestinationPathInfo[] destinationPathInfoArray)
605         {
606             return (destinationPathInfoArray != null) &&
607                 (destinationPathInfoArray.Length != 0) &&
608                 destinationPathInfoArray.All(
609                     destinationPathInfo =>
610                         {
611                             if (destinationPathInfo.BackupSourceType == BackupSourceType.File)
612                             {
613                                 return File.Exists(destinationPathInfo.Path);
614                             }
615
616                             return Directory.Exists(destinationPathInfo.Path);
617                         });
618         }
619
620         private void OnBackupSettingCreated(object sender, SettingFileEventArgs settingFileEventArgs)
621         {
622             this.IsReadyForBackup = true;
623         }
624
625         private void OnBackupSettingOpened(object sender, SettingFileEventArgs settingFileEventArgs)
626         {
627             this.IsReadyForBackup = true;
628         }
629
630         private void OnBackupSettingClosed(object sender, SettingFileEventArgs settingFileEventArgs)
631         {
632             this.IsReadyForBackup = false;
633         }
634
635         private void NotifyBackupProgress(double progressValue, IResultInfo latestResultInfo)
636         {
637             if (this.NofityFileBackupProgress != null)
638             {
639                 this.NofityFileBackupProgress(this, new FileBackupProgressEventArgs(progressValue, latestResultInfo));
640             }
641         }
642     }
643 }