//SaveWork class contructor from parameters given by the user public SaveWork(string name, string sourcePath, string destinationPath, SaveWorkType type) { this.name = name; creationTime = DateTime.Now.ToString(); this.sourcePath = sourcePath; this.destinationPath = destinationPath; this.type = type; isActive = false; saveProgress = null; }
//SaveWork class contructor from parameters given by the user public SaveWork(string _name, string _sourcePath, string _destinationPath, SaveWorkType _type) { Name = _name; CreationTime = DateTime.Now.ToString(); SourcePath = _sourcePath; DestinationPath = _destinationPath; Type = _type; IsActive = false; SaveProgress = null; }
/// <summary> /// Complete Save Work constructor /// </summary> /// <param name="_name">Save Work Name</param> /// <param name="_source">Directory Source Path</param> /// <param name="_target">Directory Target Destination Path</param> /// <param name="_extension">Extension List to Encrypt</param> /// <param name="_type">Save Work Type</param> public CompleteSaveWork(string _name, string _source, string _target, List <Extension> _extension, SaveWorkType _type) { Name = _name; SourcePath = _source; DestinationPath = _target; type = _type; ExtentionToEncryptList = _extension; CreationTime = DateTime.Now.ToString(); IsActive = false; //Progress = null; }
/// <summary> /// Confirm changes and save them to the existing object. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ConfirmModifyClick(object sender, RoutedEventArgs e) { if (!Regex.IsMatch(SaveNameForm.Text, @"^[a-zA-Z0-9 '_]{3,50}$") || !Regex.IsMatch(SaveSourcePathForm.Text, @"^[a-zA-Z]:(?:[\/\\][a-zA-Z0-9 _#]+)*$") || !Regex.IsMatch(SaveDestinationPathForm.Text, @"^[a-zA-Z]:(?:[\/\\][a-zA-Z0-9 _#]+)*$") || SaveTypeForm.SelectedItem == null) { MessageBox.Show(Properties.Langs.Lang.ConfirmBoxFormError, Properties.Langs.Lang.Warning, MessageBoxButton.OK, MessageBoxImage.Warning); } else { ChangeUIElementVisibilityState(confirmButtonList, Visibility.Hidden); ISaveWork selectedItem = (ISaveWork)SaveList.SelectedItem; List <Extension> extensionList = new List <Extension>(); if (ALL.IsChecked == false) { foreach (CheckBox _checkBox in CheckBoxList) { if (_checkBox.IsChecked == true) { Enum.TryParse(_checkBox.Name.ToLower(), out Extension _extension); extensionList.Add(_extension); } } } else { extensionList.Add(Extension.ALL); } SaveWorkType saveType = SaveWorkType.complete; if (SaveTypeForm.SelectedIndex != 0) { saveType = SaveWorkType.differencial; } VM.ModifySaveProcedure(selectedItem.Index, SaveNameForm.Text, SaveSourcePathForm.Text.Replace("\\", "/"), SaveDestinationPathForm.Text.Replace("\\", "/"), saveType, extensionList); ClearForm(); ChangeUIElementEnableState(FormElementList, false); ChangeUIElementEnableState(OptionButtonList, true); ChangeUIElementEnableState(SelectionButtonList, true); ALL.IsEnabled = false; ChangeUIElementEnableState(CheckBoxList, false); ChangeUIElementEnableState(SelectionButtonList, false); SaveList.Items.Refresh(); SaveList.SelectedItem = null; IsAnItemSelected = false; } }
private void CreateSave() { string[] saveProcedure = View.CreateSaveProcedure(); SaveWorkType type = SaveWorkType.unset; if (saveProcedure[3] == "1") { type = SaveWorkType.complete; } else if (saveProcedure[3] == "2") { type = SaveWorkType.differencial; } Model.CreateWork(int.Parse(saveProcedure[4]), saveProcedure[0], saveProcedure[1], saveProcedure[2], type); ShowMenu(); return; }
/// <summary> /// Modify value of save works objects stored in workList, if there is any null parameters the value attached isn't changed /// </summary> /// <param name="_nb">Index of the work you want to change in the list</param> /// <param name="_name">New name to apply to the work</param> /// <param name="_sourcePath">New source path to apply to the work</param> /// <param name="_destinationPath">New target destination path to apply to the work</param> /// <param name="_type">New type of save work to apply to the work</param> public void ChangeWork(int _nb, string _name, string _sourcePath, string _destinationPath, SaveWorkType _type, List <Extension> _extension) { if (_type != WorkList[_nb].Type && _type == SaveWorkType.complete) { WorkList[_nb] = new CompleteSaveWork(_name, _sourcePath, _destinationPath, _extension, SaveWorkType.complete); } else if (_type != WorkList[_nb].Type && _type == SaveWorkType.differencial) { WorkList[_nb] = new DifferencialSaveWork(_name, _sourcePath, _destinationPath, _extension, SaveWorkType.differencial); } else { if (_name != "") { WorkList[_nb].Name = _name; } if (_sourcePath != "") { WorkList[_nb].SourcePath = _sourcePath; } if (_destinationPath != "") { WorkList[_nb].DestinationPath = _destinationPath; } WorkList[_nb].ExtentionToEncryptList = _extension; } SetWorkIndex(); UpdateSaveFile(); EditLog.ChangeWorkLogLine(WorkList[_nb]); }
//Modify value of save works objects stored in workList, if there is any null parameters the value attached isn't changed public void ChangeWork(int _nb, string _name, string _sourcePath, string _destinationPath, SaveWorkType _type) { //modify the stateFile SaveWork backUpJobModified = new SaveWork(_name, _sourcePath, _destinationPath, _type); modifyStateFile(backUpJobModified, _nb); CreateLogLine("Modification of a existing save work in position " + _nb + ", current parameters : name : " + backupJobList[_nb - 1].name + ", source path : " + backupJobList[_nb - 1].sourcePath + ", destination path : " + backupJobList[_nb - 1].destinationPath + ", type : " + backupJobList[_nb - 1].type); }
//Can create a save work from simple parameters public void CreateWork(string _name, string _sourcePath, string _destinationPath, SaveWorkType _type) { SaveWork tempSave = new SaveWork(_name, _sourcePath, _destinationPath, _type); UpdateSaveFile(tempSave); CreateLogLine("Creation of a new save work , name : " + tempSave.name + ", source path : " + tempSave.sourcePath + ", destination path : " + tempSave.destinationPath + ", type : " + tempSave.type); }
/// <summary> /// Tells the Model to modify a save procedure /// </summary> public void ModifySaveProcedure(int _id, string _name, string _sourcePath, string _destinationPath, SaveWorkType _saveType, List <Extension> _encryptionList) { Model.ChangeWork(_id, _name, _sourcePath, _destinationPath, _saveType, _encryptionList); }
/// <summary> /// Tells the Model to create a save procedure /// </summary> public void CreateSaveProcedure(string _name, string _sourcePath, string _destinationPath, SaveWorkType _saveType, List <Extension> _extensionList) { if (_saveType == SaveWorkType.complete) { Model.CreateCompleteWork(_name, _sourcePath, _destinationPath, _extensionList); } else { Model.CreateDifferencialWork(_name, _sourcePath, _destinationPath, _extensionList); } }
//Modify value of save works objects stored in workList, if there is any null parameters the value attached isn't changed public void ChangeWork(int _nb, string _name, string _sourcePath, string _destinationPath, SaveWorkType _type) { if (_name != "") { WorkList[_nb - 1].Name = _name; } if (_sourcePath != "") { WorkList[_nb - 1].SourcePath = _sourcePath; } if (_destinationPath != "") { WorkList[_nb - 1].DestinationPath = _destinationPath; } if (_type != SaveWorkType.unset) { WorkList[_nb - 1].Type = _type; } UpdateSaveFile(_nb); CreateLogLine("Modification of a existing save work in position " + _nb + ", current parameters : name : " + WorkList[_nb - 1].Name + ", source path : " + WorkList[_nb - 1].SourcePath + ", destination path : " + WorkList[_nb - 1].DestinationPath + ", type : " + WorkList[_nb - 1].Type); }
//Can create a save work from simple parameters public void CreateWork(int _nb, string _name, string _sourcePath, string _destinationPath, SaveWorkType _type) { SaveWork tempSave = new SaveWork(_name, _sourcePath, _destinationPath, _type); WorkList[_nb - 1] = tempSave; UpdateSaveFile(_nb); CreateLogLine("Creation of a new save work in position " + _nb + ", name : " + tempSave.Name + ", source path : " + tempSave.SourcePath + ", destination path : " + tempSave.DestinationPath + ", type : " + tempSave.Type); }