コード例 #1
0
        public RenameTaskForm(SyncProfile profile, SyncTask task, string metaDataDir)
        {
            InitializeComponent();

            _currentProfile = profile;
            _currentTask = task;
            this._metaDataDir = metaDataDir;
        }
コード例 #2
0
ファイル: TaskSetupForm.cs プロジェクト: riverstore/syncsharp
        public TaskSetupForm(SyncProfile profile, SyncTask task, string metaDataDir)
        {
            InitializeComponent();
            _currentTask = task;
            _currentProfile = profile;
            this._metaDataDir = metaDataDir;

            ReadUserSettings();
            this.tcTaskSetup.TabPages.Remove(tcTaskSetup.TabPages["tpCopyDel"]);
            this.tcTaskSetup.TabPages.Remove(tcTaskSetup.TabPages["tpLogSettings"]);
        }
コード例 #3
0
ファイル: FolderFilter.cs プロジェクト: riverstore/syncsharp
        public FolderFilter(SyncTask task)
        {
            InitializeComponent();

            currentTask = task;

            srcTreeView.Nodes.Add(currentTask.Source);
            tarTreeView.Nodes.Add(currentTask.Target);

            srcTreeView.ImageList = imageList;
            tarTreeView.ImageList = imageList;
        }
コード例 #4
0
ファイル: FolderFilter.cs プロジェクト: riverstore/syncsharp
        public FolderFilter(SyncTask task)
        {
            InitializeComponent();

            currentTask = task;

            srcTreeView.Nodes.Add(currentTask.Source);
            tarTreeView.Nodes.Add(currentTask.Target);

            srcTreeView.ImageList = imageList;
            tarTreeView.ImageList = imageList;

            initSourceTreeView = new PopulateTreeViewCallback(PopulateTreeView);
            initTargetTreeView = new PopulateTreeViewCallback(PopulateTreeView);
        }
コード例 #5
0
 public FolderDiffForm(CustomDictionary<string,string, PreviewUnit> previewFilesList,
     CustomDictionary<string,string, PreviewUnit> previewFoldersList,
     SyncTask task)
 {
     InitializeComponent();
     _previewFilesList = previewFilesList;
     _previewFoldersList = previewFoldersList;
     _source = task.Source;
     _target = task.Target;
     _sortColumn = -1;
     lblName.Text = task.Name;
     lblSource.Text = _source;
     lblTarget.Text = _target;
     _filter = "";
     this.Text = "[" + lblName.Text + "] Synchronization Preview";
 }
コード例 #6
0
ファイル: Validation.cs プロジェクト: riverstore/syncsharp
        /// <summary>
        /// Performs validation source and target directories
        /// </summary>
        /// <param name="source">Full path of source directory</param>
        /// <param name="target">Full path of target directory</param>
        /// <param name="profile">The profile of the current PC</param>
        /// <param name="chkDuplicateFolderPair">Boolean to indicate whether to check for duplicate folder pair</param>
        /// <returns>The error msg code of the error that occurs</returns>
        public static ErrorMsgCode CheckFolderPair(ref string source, ref string target, 
            SyncProfile profile, SyncTask task)
        {
            if (String.IsNullOrEmpty(source.Trim()))
                return ErrorMsgCode.EmptySource;

            if (String.IsNullOrEmpty(target.Trim()))
                return ErrorMsgCode.EmptyTarget;

            if (!Directory.Exists(source))
                return ErrorMsgCode.InvalidSource;

            if (!Directory.Exists(target))
                return ErrorMsgCode.InvalidTarget;

            source = Path.GetFullPath(source);
            target = Path.GetFullPath(target);

            source = source.EndsWith("\\") ? source : source + "\\";
            target = target.EndsWith("\\") ? target : target + "\\";

            if (String.Compare(source, target, true) == 0)
                return ErrorMsgCode.SameSourceTarget;

            if (source.StartsWith(target, true, null))
                return ErrorMsgCode.SourceIsASubDirOfTarget;

            if (target.StartsWith(source, true, null))
                return ErrorMsgCode.TargetIsASubDirOfSource;

            StringComparison ignoreCase = StringComparison.CurrentCultureIgnoreCase;

            bool chkDuplicateFolderPair = true;

            if (task != null)
            {
              chkDuplicateFolderPair = !((task.Source.Equals(source, ignoreCase) &&
                     task.Target.Equals(target, ignoreCase)) ||
                     (task.Source.Equals(target, ignoreCase) &&
                     task.Target.Equals(source, ignoreCase)));
            }

            if (chkDuplicateFolderPair && profile.IsFolderPairExists(source, target))
                return ErrorMsgCode.DuplicateFolderPair;

            return ErrorMsgCode.NoError;
        }
コード例 #7
0
ファイル: Detector.cs プロジェクト: riverstore/syncsharp
 public Detector(String metaDataDir, SyncTask syncTask)
 {
     _sCleanFiles = new CustomDictionary<string, string, FileUnit>();
     _sDirtyFiles = new CustomDictionary<string, string, FileUnit>();
     _tCleanFiles = new CustomDictionary<string, string, FileUnit>();
     _tDirtyFiles = new CustomDictionary<string, string, FileUnit>();
     _sDirtyDirs = new CustomDictionary<string, string, FileUnit>();
     _sCleanDirs = new CustomDictionary<string, string, FileUnit>();
     _tDirtyDirs = new CustomDictionary<string, string, FileUnit>();
     _tCleanDirs = new CustomDictionary<string, string, FileUnit>();
     _backupFiles = new CustomDictionary<string, string, FileUnit>();
     _fileExclusions = new List<string>();
     _task = syncTask;
     _sMetaData = SyncMetaData.ReadMetaData(metaDataDir + @"\" + syncTask.Name + ".meta");
     _tMetaData = SyncMetaData.ReadMetaData(metaDataDir + @"\" + syncTask.Name + ".meta");
     _srcDirtySize = 0;
     _tgtDirtySize = 0;
 }
コード例 #8
0
ファイル: Reconciler.cs プロジェクト: riverstore/syncsharp
        public Reconciler(FileList srcList, FileList tgtList, SyncTask task, String metaDataDir)
        {
            _srcList = srcList;
            _tgtList = tgtList;
            _taskSettings = task.Settings;
            _srcPath = task.Source;
            _tgtPath = task.Target;
            _taskName = task.Name;
            _errorDetected = false;

            _previewFilesList = new CustomDictionary<string, string, PreviewUnit>();
            _previewFoldersList = new CustomDictionary<string, string, PreviewUnit>();
            _updatedList = new CustomDictionary<string, string, FileUnit>();
            _srcRenameList = new CustomDictionary<string, string, FileUnit>();
            _tgtRenameList = new CustomDictionary<string, string, FileUnit>();

            _summary = new SyncSummary();
            _summary.logFile = metaDataDir + @"\" + task.Name + ".log";
        }
コード例 #9
0
ファイル: SyncProfile.cs プロジェクト: riverstore/syncsharp
        internal void copyTask(string name)
        {
            SyncTask newTask = new SyncTask();
            SyncTask temp = getTask(name);
            newTask.Source = temp.Source;
            newTask.Target = temp.Target;
            newTask.Result = "";
            newTask.LastRun = "Never";
            newTask.TypeOfSync = temp.TypeOfSync;
            newTask.Settings = temp.Settings;
            newTask.Filters = temp.Filters;
            newTask.SrcOnRemovable = temp.SrcOnRemovable;
            newTask.DestOnRemovable = temp.DestOnRemovable;

            int newValue;
            if (!temp.Name.Contains("("))
            {
                newTask.Name = temp.Name + " Copy(1)";
                newValue = 0;
                while (true)
                {
                    newValue++;
                    newTask.Name = newTask.Name.Substring(0, newTask.Name.LastIndexOf("(") + 1) +
                        newValue.ToString() + ")";
                    if (!taskExists(newTask.Name)) break;
                }
            }
            else
            {
                newValue = Int32.Parse(temp.Name.Substring(temp.Name.LastIndexOf("(") + 1,
                    temp.Name.LastIndexOf(")") - temp.Name.LastIndexOf("(") - 1));

                while (true)
                {
                    newValue++;
                    newTask.Name = temp.Name.Substring(0, temp.Name.LastIndexOf("(") + 1) +
                        newValue.ToString() + ")";
                    if (!taskExists(newTask.Name)) break;
                }
            }
            taskCollection.Add(newTask);
        }
コード例 #10
0
        public DialogResult AnalyzeFolderPair(SyncTask curTask)
        {
            DialogResult result = DialogResult.None;
            try
            {
                this.NotifyUIs("Analyzing " + curTask.Name + "...");
                Detector detector = new Detector(_metaDataDir, curTask);
                detector.CompareFolders();
                if (!detector.IsSynchronized())
                {
                    if (!CheckSufficientDiskSpace(curTask.Source.Substring(0, 1), detector.TgtDirtySize, false) ||
                            !CheckSufficientDiskSpace(curTask.Target.Substring(0, 1), detector.SrcDirtySize, false))
                    {
                        throw new Exception("Insufficient disk space");
                    }
                    _previewReconciler = new Reconciler(detector.SourceList, detector.TargetList, curTask, _metaDataDir);
                    _previewReconciler.Preview();
                    FolderDiffForm form = new FolderDiffForm(_previewReconciler.PreviewFilesList,
                                                            _previewReconciler.PreviewFoldersList, curTask);
                    this.NotifyUIs("Analysis completed");
                    result = form.ShowDialog();
                }
                else
                {
                    this.NotifyUIs("Analysis completed");
                    MessageBox.Show("Task: " + curTask.Name + "\n\n" +
                    "There are no differences between the source and target folders contents.",
                    "SyncSharp", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.UpdateSyncTaskResult(curTask, "Successful");
                }
            }
            catch (Exception e)
            {
                Logger.LogFileLocation = _metaDataDir + @"\";
                Logger.LogFileName = Logger.LogFileLocation + curTask.Name + ".log";
                Logger.WriteErrorLog(e.Message);
                this.UpdateSyncTaskResult(curTask, "Unsuccessful");
            }

            this.UpdateSyncTaskTime(curTask, DateTime.Now.ToString());
            return result;
        }
コード例 #11
0
ファイル: MainForm.cs プロジェクト: riverstore/syncsharp
 private void AddTaskViewItem(SyncTask item)
 {
     ListViewItem lvi = new ListViewItem(item.Name);
     string type = (item.TypeOfSync) ? "Synchronize" : "Backup";
     lvi.SubItems.Add(type);
     lvi.SubItems.Add(item.LastRun);
     lvi.SubItems.Add(item.Result);
     lvi.SubItems.Add(item.Source);
     lvi.SubItems.Add(item.Target);
     taskListView.Items.Add(lvi);
 }
コード例 #12
0
		public RenameTaskForm(SyncProfile profile, SyncTask task)
		{
			currentProfile = profile;
			currentTask = task;
			InitializeComponent();
		}
コード例 #13
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (state == 1)
            {
                if (logic.Profile.taskExists(GetTaskName.Trim()))
                {
                    MessageBox.Show("Task name '" + GetTaskName.Trim() +
                        "' already exists, please choose a unique name",
                        "SyncSharp", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (GetTaskName.Trim().Equals(""))
                {
                    MessageBox.Show("Please enter a task name",
                        "SyncSharp", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    GetTaskNamePanel.Hide();
                    GetSelectTypePanel.Show();
                    GetFolderPairPanel.Hide();
                    state = 2;
                }
            }
            else if (state == 2)
            {
                if (!radBackup.Checked && !radSync.Checked)
                {
                    MessageBox.Show("Please choose a synchronization type",
                        "SyncSharp", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    GetTaskNamePanel.Hide();
                    GetSelectTypePanel.Hide();
                    GetFolderPairPanel.Show();
                    btnNext.Text = "Done";
                    btnNext.ImageIndex = 1;
                    btnNext.TextImageRelation = TextImageRelation.ImageBeforeText;
                    state = 3;
                }
            }
            else if (state == 3)
            {
                if (CheckFolderPair())
                {
                    try
                    {
                        String root = Path.GetPathRoot(Directory.GetCurrentDirectory());
                        root = root.Substring(0, 1);
                        SyncTask task = new SyncTask(GetTaskName, GetSource, GetTarget, GetTaskType,
                            GetSource.StartsWith(root), GetTarget.StartsWith(root));
                        logic.Profile.addTask(task);

                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
コード例 #14
0
 public void UpdateSyncTaskTime(SyncTask task, string time)
 {
     _currentProfile.UpdateSyncTaskTime(task, time);
 }
コード例 #15
0
 public void UpdateSyncTaskResult(SyncTask task, string result)
 {
     _currentProfile.UpdateSyncTaskResult(task, result);
 }
コード例 #16
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            if (!ValidateUserInput()) return;

            try
            {
                String root = Path.GetPathRoot(Directory.GetCurrentDirectory());
                root = root.Substring(0, 1);

                SyncTask task = new SyncTask(txtName.Text.Trim(), _source, _target, radSync.Checked,
                                            _source.StartsWith(root), _target.StartsWith(root),
                                            new TaskSettings(), new Filters());
                _logic.Profile.AddTask(task);
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #17
0
ファイル: SyncProfile.cs プロジェクト: riverstore/syncsharp
 /// <summary>
 /// Updates the specified SyncTask with the Result status
 /// </summary>
 /// <param name="task"></param>
 /// <param name="result"></param>
 public void UpdateSyncTaskResult(SyncTask task, string result)
 {
     task.Result = result;
 }
コード例 #18
0
ファイル: ATD.cs プロジェクト: riverstore/syncsharp
        private void SimulateChanges(SyncTask curTask, string[] performChanges)
        {
            Console.WriteLine("Simulating changes to files/directories...");
            Thread.Sleep(15);
            foreach (string changes in performChanges)
            {
                String type = changes.Trim().Substring(0, 3);
                FileInfo updateFile;
                StreamWriter sw;

                #region Determine and perform changes
                switch (type)
                {
                    case "FCR":
                        updateFile = new FileInfo(curTask.Target + changes.Trim().Substring(4));
                        if (!updateFile.Directory.Exists)
                            Directory.CreateDirectory(updateFile.DirectoryName);
                        sw = updateFile.CreateText();
                        sw.Close();
                        Console.WriteLine("Creating file " + changes.Trim().Substring(4) + " on _target...");
                        break;
                    case "FCL":
                        updateFile = new FileInfo(curTask.Source + changes.Trim().Substring(4));
                        if (!updateFile.Directory.Exists)
                            Directory.CreateDirectory(updateFile.DirectoryName);
                        sw = updateFile.CreateText();
                        sw.Close();
                        Console.WriteLine("Creating file " + changes.Trim().Substring(4) + " on _source...");
                        break;
                    case "FMR":
                        sw = File.AppendText(curTask.Target + changes.Trim().Substring(4));
                        sw.WriteLine("New info");
                        sw.Close();
                        Console.WriteLine("Modifying file " + changes.Trim().Substring(4) + " on _target...");
                        break;
                    case "FML":
                        sw = File.AppendText(curTask.Source + changes.Trim().Substring(4));
                        sw.WriteLine("New info");
                        sw.Close();
                        Console.WriteLine("Modifying file " + changes.Trim().Substring(4) + " on _source...");
                        break;
                    case "FDR":
                        File.Delete(curTask.Target + changes.Trim().Substring(4));
                        Console.WriteLine("Deleting file " + changes.Trim().Substring(4) + " on _target...");
                        break;
                    case "FDL":
                        File.Delete(curTask.Source + changes.Trim().Substring(4));
                        Console.WriteLine("Deleting file " + changes.Trim().Substring(4) + " on _source...");
                        break;
                    case "FRR":
                        File.Move(curTask.Target + changes.Trim().Substring(4), curTask.Target + @"\Rename" + changes.Trim().Substring(5));
                        Console.WriteLine("Renaming file " + changes.Trim().Substring(4) + " on _target...");
                        break;
                    case "FRL":
                        File.Move(curTask.Source + changes.Trim().Substring(4), curTask.Source + @"\Rename" + changes.Trim().Substring(5));
                        Console.WriteLine("Renaming file " + changes.Trim().Substring(4) + " on _source...");
                        break;
                    case "DCR":
                        Directory.CreateDirectory(curTask.Target + changes.Trim().Substring(4));
                        Console.WriteLine("Creating directory " + changes.Trim().Substring(4) + " on _target...");
                        break;
                    case "DCL":
                        Directory.CreateDirectory(curTask.Source + changes.Trim().Substring(4));
                        Console.WriteLine("Creating directory " + changes.Trim().Substring(4) + " on _source...");
                        break;
                    case "DDR":
                        Directory.Delete(curTask.Target + changes.Trim().Substring(4), true);
                        Console.WriteLine("Deleting directory " + changes.Trim().Substring(4) + " on _target...");
                        break;
                    case "DDL":
                        Directory.Delete(curTask.Source + changes.Trim().Substring(4), true);
                        Console.WriteLine("Deleting directory " + changes.Trim().Substring(4) + " on _source...");
                        break;
                    case "DRR":
                        Directory.Move(curTask.Target + changes.Trim().Substring(4), curTask.Target + @"\Rename" + changes.Trim().Substring(5));
                        Console.WriteLine("Renaming directory " + changes.Trim().Substring(4) + " on _target...");
                        break;
                    case "DRL":
                        Directory.Move(curTask.Source + changes.Trim().Substring(4), curTask.Source + @"\Rename" + changes.Trim().Substring(5));
                        Console.WriteLine("Renaming directory " + changes.Trim().Substring(4) + " on _source...");
                        break;
                }
                #endregion
            }
        }
コード例 #19
0
ファイル: ATD.cs プロジェクト: riverstore/syncsharp
 private void CreateTestDirectories(SyncTask curTask)
 {
     Console.WriteLine("Creating Source and Target directories...");
     Directory.CreateDirectory(curTask.Source);
     Directory.CreateDirectory(curTask.Target);
 }
コード例 #20
0
ファイル: ATD.cs プロジェクト: riverstore/syncsharp
        private void TestCompareFolders(TestCase t, SyncTask curTask)
        {
            RemoveExistingDirectories(curTask);
            Thread.Sleep(25);
            CreateTestDirectories(curTask);
            Thread.Sleep(25);

            CustomDictionary<String, String, FileUnit> srcMeta = new CustomDictionary<string, string, FileUnit>();
            CustomDictionary<String, String, FileUnit> tgtMeta = new CustomDictionary<string, string, FileUnit>();
            int srcLength = curTask.Source.Length;
            int tgtLength = curTask.Target.Length;
            char[] delimiters = new char[] { ',' };

            String createScenario = t.Param2;
            String[] createFiles = createScenario.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

            CreateOldState(curTask, t, createFiles, srcMeta, srcLength, tgtMeta, tgtLength);
            Thread.Sleep(25);

            String scenario = t.Param3;
            String[] performChanges = scenario.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

            SimulateChanges(curTask, performChanges);

            Detector tester;
            TestCompareFolders(curTask, t, srcMeta, tgtMeta, out tester);

            TestCompareFoldersOutput(t, tester);
        }
コード例 #21
0
ファイル: SyncProfile.cs プロジェクト: riverstore/syncsharp
 /// <summary>
 /// Adds a new SyncTask to the collection
 /// </summary>
 /// <param name="task"></param>
 public void AddTask(SyncTask task)
 {
     if (this.TaskExists(task.Name))
         throw new ApplicationException("Task Name already Exists in this Profile");
     _taskCollection.Add(task);
 }
コード例 #22
0
ファイル: SyncProfile.cs プロジェクト: riverstore/syncsharp
 /// <summary>
 /// Updates the specified SyncTask with the Last Run sync time
 /// </summary>
 /// <param name="task"></param>
 /// <param name="time"></param>
 public void UpdateSyncTaskTime(SyncTask task, string time)
 {
     task.LastRun = time;
 }
コード例 #23
0
ファイル: ATD.cs プロジェクト: riverstore/syncsharp
        private void TestAddTask(TestCase t, SyncProfile curProfile)
        {
            char[] delimiters = new char[] { ',' };
            String parameters = t.Param1;
            String[] inputParameters = parameters.Split(delimiters);
            Validation.ErrorMsgCode errorTaskName = Validation.CheckTaskName(inputParameters[0], curProfile);
            Validation.ErrorMsgCode errorDuplicate = Validation.CheckFolderPair(ref inputParameters[1], ref inputParameters[2], curProfile, null);

            if (errorTaskName == Validation.ErrorMsgCode.NoError && errorDuplicate == Validation.ErrorMsgCode.NoError)
            {
                SyncTask newTask = new SyncTask(inputParameters[0], inputParameters[1], inputParameters[2]);
                curProfile.AddTask(newTask);
            }

            #region Get error msg code for task name
            switch (errorTaskName)
            {
                case Validation.ErrorMsgCode.EmptyTaskName:
                    t.Actual = "EmptyTaskName";
                    break;
                case Validation.ErrorMsgCode.DuplicateTaskName:
                    t.Actual = "DuplicateTaskName";
                    break;
                case Validation.ErrorMsgCode.InvalidTaskName:
                    t.Actual = "InvalidTaskName";
                    break;
                default:
                    t.Actual = "NoError";
                    break;
            }
            #endregion

            #region Get error msg code for folder pair
            switch (errorDuplicate)
            {
                case Validation.ErrorMsgCode.EmptySource:
                    t.Actual += " EmptySource";
                    break;
                case Validation.ErrorMsgCode.EmptyTarget:
                    t.Actual += " EmptyTarget";
                    break;
                case Validation.ErrorMsgCode.InvalidSource:
                    t.Actual += " InvalidSource";
                    break;
                case Validation.ErrorMsgCode.InvalidTarget:
                    t.Actual += " InvalidTarget";
                    break;
                case Validation.ErrorMsgCode.SameSourceTarget:
                    t.Actual += " SameSourceTarget";
                    break;
                case Validation.ErrorMsgCode.SourceIsASubDirOfTarget:
                    t.Actual += " SourceIsASubDirOfTarget";
                    break;
                case Validation.ErrorMsgCode.TargetIsASubDirOfSource:
                    t.Actual += " TargetIsASubDirOfSource";
                    break;
                case Validation.ErrorMsgCode.DuplicateFolderPair:
                    t.Actual += " DuplicateFolderPair";
                    break;
                default:
                    t.Actual += " NoError";
                    break;
            }
            #endregion

            t.Passed = (t.Actual.Equals(t.Param2)) ? true : false;
            if (t.Passed) _totalPassed++;
            else _totalFailed++;
        }
コード例 #24
0
ファイル: TaskSetupForm.cs プロジェクト: riverstore/syncsharp
 public TaskSetupForm(SyncTask task)
 {
     currentTask = task;
     InitializeComponent();
 }
コード例 #25
0
        public void RestoreSource(SyncTask curTask)
        {
            try
            {
                Logger.LogFileLocation = _metaDataDir + @"\";
                Logger.LogFileName = Logger.LogFileLocation + curTask.Name + ".log";

                Reconciler reconciler = new Reconciler(null, null, curTask, _metaDataDir);
                reconciler.RestoreSource(SyncMetaData.ReadMetaData(_metaDataDir + @"\" + curTask.Name + ".bkp"));
                this.UpdateSyncTaskResult(curTask, "Successful");
            }
            catch (Exception e)
            {
                Logger.WriteErrorLog(e.Message);
                this.UpdateSyncTaskResult(curTask, "Unsuccessful");
            }
        }
コード例 #26
0
ファイル: SyncProfile.cs プロジェクト: riverstore/syncsharp
 /// <summary>
 /// Removes a SyncTask from the collection
 /// </summary>
 /// <param name="task"></param>
 /// <param name="metaDataDir"></param>
 public void RemoveTask(SyncTask task, string metaDataDir)
 {
     if (task == null)
         throw new ApplicationException("Task Name does not Exist in this Profile");
     _taskCollection.Remove(task);
     if (File.Exists(metaDataDir + @"\" + task.Name + ".meta"))
         File.Delete(metaDataDir + @"\" + task.Name + ".meta");
     if (File.Exists(metaDataDir + @"\" + task.Name + ".log"))
         File.Delete(metaDataDir + @"\" + task.Name + ".log");
     if (File.Exists(metaDataDir + @"\" + task.Name + ".bkp"))
         File.Delete(metaDataDir + @"\" + task.Name + ".bkp");
 }
コード例 #27
0
ファイル: ATD.cs プロジェクト: riverstore/syncsharp
        private void RemoveExistingDirectories(SyncTask curTask)
        {
            bool srcNotDeleted = true;
            bool tgtNotDeleted = true;

            while (srcNotDeleted || tgtNotDeleted)
            {
                try
                {
                    #region Remove source directories
                    if (Directory.Exists(curTask.Source))
                    {
                        Directory.Delete(curTask.Source, true);
                        Console.WriteLine("Source Exists...Deleting...");
                        srcNotDeleted = false;
                    }
                    else
                    {
                        srcNotDeleted = false;
                    }
                    #endregion

                    #region Remove target directories
                    if (Directory.Exists(curTask.Target))
                    {
                        Directory.Delete(curTask.Target, true);
                        Console.WriteLine("Target Exists...Deleting...");
                        tgtNotDeleted = false;
                    }
                    else
                    {
                        tgtNotDeleted = false;
                    }
                    #endregion

                }
                catch
                {
                }
            }
        }
コード例 #28
0
        /*
        public DialogResult AnalyzeFolderPair(SyncTask curTask)
        {
            DialogResult result = DialogResult.None;
            try
            {
                this.NotifyUIs("Analyzing " + curTask.Name + "...");
                Detector detector = new Detector(_metaDataDir, curTask);
                detector.CompareFolders();
                if (!detector.IsSynchronized())
                {
                    if (!CheckSufficientDiskSpace(curTask.Source.Substring(0, 1), detector.TgtDirtySize, false) ||
                            !CheckSufficientDiskSpace(curTask.Target.Substring(0, 1), detector.SrcDirtySize, false))
                    {
                        throw new Exception("Insufficient disk space");
                    }
                    _previewReconciler = new Reconciler(detector.SourceList, detector.TargetList, curTask, _metaDataDir);
                    _previewReconciler.Preview();
                    FolderDiffForm form = new FolderDiffForm(_previewReconciler.PreviewFilesList,
                                                            _previewReconciler.PreviewFoldersList, curTask);
                    this.NotifyUIs("Analysis completed");
                    result = form.ShowDialog();
                }
                else
                {
                    this.NotifyUIs("Analysis completed");
                    MessageBox.Show("Task: " + curTask.Name + "\n\n" +
                    "There are no differences between the source and target folders contents.",
                    "SyncSharp", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.UpdateSyncTaskResult(curTask, "Successful");
                }
            }
            catch (Exception e)
            {
                Logger.LogFileLocation = _metaDataDir + @"\";
                Logger.LogFileName = Logger.LogFileLocation + curTask.Name + ".log";
                Logger.WriteErrorLog(e.Message);
                this.UpdateSyncTaskResult(curTask, "Unsuccessful");
            }

            this.UpdateSyncTaskTime(curTask, DateTime.Now.ToString());
            return result;
        }
        */
        public void SyncAfterAnalyze(SyncTask curTask)
        {
            try
            {
                Logger.WriteSyncLog(_metaDataDir, curTask.Name, true);
                this.NotifyUIs("Synchronizing " + curTask.Name + "...");
                _previewReconciler.SyncPreview();

                SyncMetaData.WriteMetaData(_metaDataDir + @"\" + curTask.Name + ".meta", _previewReconciler.UpdatedList);

                this.UpdateSyncTaskResult(curTask, "Successful");
            }
            catch (Exception e)
            {
                Logger.WriteErrorLog(e.Message);
                this.UpdateSyncTaskResult(curTask, "Unsuccessful");
            }
            finally
            {
                Logger.WriteSyncLog(_metaDataDir, curTask.Name, false);
            }

            this.UpdateSyncTaskTime(curTask, DateTime.Now.ToString());
        }
コード例 #29
0
        public void SyncFolderPair(SyncTask curTask, bool disablePrompt)
        {
            try
            {
                Logger.WriteSyncLog(_metaDataDir, curTask.Name, true);
                this.NotifyUIs("Analyzing " + curTask.Name + "...");

                Detector detector = new Detector(_metaDataDir, curTask);
                detector.CompareFolders();

                if (!detector.IsSynchronized())
                {
                    if (!CheckSufficientDiskSpace(curTask.Source.Substring(0, 1), detector.TgtDirtySize, disablePrompt) ||
                            !CheckSufficientDiskSpace(curTask.Target.Substring(0, 1), detector.SrcDirtySize, disablePrompt))
                    {
                        throw new Exception("Insufficient disk space");
                    }

                    Reconciler reconciler = new Reconciler(detector.SourceList, detector.TargetList, curTask, _metaDataDir);
                    this.NotifyUIs("Synchronizing " + curTask.Name + "...");

                    if (curTask.TypeOfSync)
                    {
                        reconciler.Sync();
                        SyncMetaData.WriteMetaData(_metaDataDir + @"\" + curTask.Name + ".meta", reconciler.UpdatedList);
                    }
                    else
                    {
                        reconciler.BackupSource(detector.BackupFiles);
                        SyncMetaData.WriteMetaData(_metaDataDir + @"\" + curTask.Name + ".bkp", detector.BackupFiles);
                    }
                }

                this.UpdateSyncTaskResult(curTask, "Successful");
            }
            catch (Exception e)
            {
                Logger.WriteErrorLog(e.Message);
                this.UpdateSyncTaskResult(curTask, "Unsuccessful");
            }
            finally
            {
                Logger.WriteSyncLog(_metaDataDir, curTask.Name, false);
            }

            this.UpdateSyncTaskTime(curTask, DateTime.Now.ToString());
        }
コード例 #30
0
ファイル: ATD.cs プロジェクト: riverstore/syncsharp
        private void TestCompareFolders(SyncTask curTask, TestCase t, CustomDictionary<string, string, FileUnit> srcMeta, CustomDictionary<string, string, FileUnit> tgtMeta, out Detector tester)
        {
            Console.WriteLine("Performing compareFolders()...");
            tester = new Detector("TestCases", curTask);
            if (t.Param1.Equals("Y"))
            {
                tester.SMetaData = srcMeta;
                tester.TMetaData = tgtMeta;
            }
            else
            {
                tester.SMetaData = null;
                tester.TMetaData = null;
            }

            tester.CompareFolders();
        }