public RenameTaskForm(SyncProfile profile, SyncTask task, string metaDataDir) { InitializeComponent(); _currentProfile = profile; _currentTask = task; this._metaDataDir = metaDataDir; }
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"]); }
/// <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; }
public RenameTaskForm(SyncProfile profile, SyncTask task) { currentProfile = profile; currentTask = task; InitializeComponent(); }
/// <summary> /// Perform validation on task name /// </summary> /// <param name="taskName">The task name to be validated</param> /// <param name="profile">The profile of the current PC</param> /// <returns>The error msg code of the error that occurs</returns> public static ErrorMsgCode CheckTaskName(string taskName, SyncProfile profile) { if (taskName.Trim().Equals("")) return ErrorMsgCode.EmptyTaskName; if (profile.TaskExists(taskName.Trim())) return ErrorMsgCode.DuplicateTaskName; string invalidChars = Regex.Escape(new string(Path.GetInvalidFileNameChars())); invalidChars = string.Format(@"[{0}]", invalidChars); if (Regex.IsMatch(taskName.Trim(), invalidChars)) return ErrorMsgCode.InvalidTaskName; return ErrorMsgCode.NoError; }
private void ReadSettings(SyncProfile currentProfile) { countDown.Value = currentProfile.CountDown; enableAutoPlay.Checked = currentProfile.AutoPlay; }
private void SaveSettings(SyncProfile currentProfile) { currentProfile.AutoPlay = enableAutoPlay.Checked; currentProfile.CountDown = (int)countDown.Value; }
public void ModifyGlobalSettings(SyncProfile currentProfile) { GlobalSettings form = new GlobalSettings(currentProfile); form.ShowDialog(); }
public GlobalSettings(SyncProfile profile) { InitializeComponent(); _currentProfile = profile; ReadSettings(_currentProfile); }
public void LoadProfile() { string ID = GetMachineID(); _metaDataDir = @".\Profiles\" + ID; if (CheckProfileExists(ID)) { Stream str = null; try { str = File.OpenRead(_metaDataDir + @"\" + ID); BinaryFormatter formatter = new BinaryFormatter(); _currentProfile = (SyncProfile)formatter.Deserialize(str); } catch (Exception e) { Logger.WriteSystemErrorLog(e.StackTrace); } finally { if (str != null) str.Close(); } try { if (_currentProfile == null) File.Delete(_metaDataDir + @"\" + ID); } catch (Exception) { } } if (_currentProfile == null) _currentProfile = new SyncProfile(ID); }
public void LoadProfile() { string ID = GetMachineID(); _metaDataDir = @".\Profiles\" + ID; if (CheckProfileExists(ID)) { Stream str = File.OpenRead(_metaDataDir + @"\" + ID); try { BinaryFormatter formatter = new BinaryFormatter(); _currentProfile = (SyncProfile)formatter.Deserialize(str); } catch { } finally { str.Close(); } if (_currentProfile == null) File.Delete(_metaDataDir + @"\" + ID); } if (_currentProfile == null) _currentProfile = new SyncProfile(ID); }
private void TestRemoveTask(TestCase t, SyncProfile curProfile) { char[] delimiters = new char[] { ',' }; String parameters = t.Param1; String[] inputParameters = parameters.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); if (curProfile.TaskExists(inputParameters[0])) { curProfile.RemoveTask(curProfile.GetTask(inputParameters[0]), ""); t.Actual = "True"; } else { t.Actual = "False"; } t.Passed = (t.Actual.Equals(t.Param2)) ? true : false; if (t.Passed) _totalPassed++; else _totalFailed++; }
private void TestGetTask(TestCase t, SyncProfile curProfile) { char[] delimiters = new char[] { ',' }; String parameters = t.Param1; String[] inputParameters = parameters.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); SyncTask retrievedTask = curProfile.GetTask(inputParameters[0]); if (retrievedTask == null) { t.Actual = "null"; } else { t.Actual = retrievedTask.Name; } t.Passed = (t.Actual.Equals(t.Param2)) ? true : false; if (t.Passed) _totalPassed++; else _totalFailed++; }
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++; }
public void ExecuteTests(SyncTask curTask, SyncProfile curProfile, SyncSharpLogic curLogic) { foreach (TestCase t in _cases) { if (t.Method.Equals("CompareFolders")) { Console.WriteLine("Performing CompareFolders Test for ID: " + t.ID); Console.WriteLine(""); TestCompareFolders(t, curTask); } else if (t.Method.Equals("Sync")) { Console.WriteLine("Performing Sync Test for ID: " + t.ID); Console.WriteLine(""); TestSync(t, curTask); } else if (t.Method.Equals("AddTask")) { Console.WriteLine("Performing AddTask Test for ID: " + t.ID); Console.WriteLine(""); TestAddTask(t, curProfile); } else if (t.Method.Equals("TaskExists")) { Console.WriteLine("Performing TaskExists check for ID: " + t.ID); Console.WriteLine(""); TestTaskExists(t, curProfile); } else if (t.Method.Equals("GetTask")) { Console.WriteLine("Performing GetTask check for ID: " + t.ID); Console.WriteLine(""); TestGetTask(t, curProfile); } else if (t.Method.Equals("RemoveTask")) { Console.WriteLine("Performing RemoveTask check for ID: " + t.ID); Console.WriteLine(""); TestRemoveTask(t, curProfile); } else if (t.Method.Equals("CheckProfileExists")) { Console.WriteLine("Performing CheckProfileExist check for ID: " + t.ID); Console.WriteLine(""); TestCheckProfileExists(t, curLogic); } else if (t.Method.Equals("LoadProfile")) { Console.WriteLine("Performing LoadProfile test for ID: " + t.ID); Console.WriteLine(""); TestLoadProfile(t, curLogic); } else if (t.Method.Equals("CheckAutorun")) { Console.WriteLine("Performing CheckAutoRun test for ID: " + t.ID); Console.WriteLine(""); TestCheckAutoRun(t, curLogic); } else throw new Exception("unsupported method " + t.Method); } }
private void TestTaskExists(TestCase t, SyncProfile curProfile) { char[] delimiters = new char[] { ',' }; String parameters = t.Param1; String[] inputParameters = parameters.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); t.Actual = curProfile.TaskExists(inputParameters[0]).ToString(); t.Passed = t.Actual.Equals(t.Param2) ? true : false; if (t.Passed) _totalPassed++; else _totalFailed++; }