public async Task UpdateSourceFolder(SourceFolder sourceFolder) { if (sourceFolder.Id == 0) { throw new ArgumentException($"Source folder ({sourceFolder.Path}) doesn't exist."); } using (var db = new DataContext()) { var dbSourceFolder = await db.SourceFolders.FindAsync(sourceFolder.Id); if (dbSourceFolder == null) { throw new ArgumentException($"Source folder ({sourceFolder.Path}) doesn't exist."); } dbSourceFolder.Path = sourceFolder.Path; dbSourceFolder.KeepRelativePath = sourceFolder.KeepRelativePath; dbSourceFolder.ObservationType = sourceFolder.ObservationType; await db.SaveChangesAsync(); } await ReFillCache <Collection>(); OnCollectionChanged(); }
private void MoveFiles2() { if (TargetFolder == null || !TargetFolder.Exists) { return; } foreach (var path in SourceFolder.EnumerateFiles()) { var f = Path.GetFileName(path.FullName); var match = Regex.Match(f, "(.*)\\.S([0-9][0-9])E([0-9][0-9])"); if (match.Success) { var name = match.Groups[1].ToString().Replace('.', ' '); var season = match.Groups[2].ToString(); var episode = match.Groups[3].ToString(); var extension = Path.GetExtension(f); var targetFilename = string.Format("{0} - S{1}E{2}{3}", name, season, episode, extension); Log(string.Format("Moving {0} to {1}", f, targetFilename)); var dir = Path.Combine(TargetFolder.FullName, name); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } var targetPath = Path.Combine(dir, targetFilename); path.MoveTo(targetPath); } } }
private async void FolderVM_SaveSourceRequest(object sender, EventArgs e) { var folderVm = (SourceFolderVM)sender; var sourceFolder = new SourceFolder( folderVm.Id, Id, folderVm.Path, folderVm.CheckFormat, folderVm.CheckNameHash, folderVm.TagsFromSubfolder, folderVm.AddTagFromFileName, folderVm.SupportedExtensionsRaw); try { if (sourceFolder.Id.HasValue) { await _sourceFolderService.UpdateSourceFolderAsync(sourceFolder); } else { await _sourceFolderService.AddSourceFolderAsync(sourceFolder); } await LoadFolders(); } catch (Exception ex) { App.MainWindowVM?.SetStatusError("Can't save folder", ex.Message); Debug.WriteLine("Can't save folder: " + ex.Message); } }
public async Task GetFiles() { await TransformText.Utils.Setup.Structure(o); Console.WriteLine(string.Join(", ", SourceFolder.GetFiles(o).Select(x => x.fi.Name))); Assert.IsTrue(SourceFolder.GetFiles(o).Any()); }
public override bool Equals(object obj) { TemplateSource other = obj as TemplateSource; if (other == null) { return(false); } if (Type != other.Type) { return(false); } if (SourceFolder != null && !SourceFolder.Equals(other.SourceFolder)) { return(false); } if (GitUrl != null && !GitUrl.Equals(other.GitUrl)) { return(false); } if (PackageVersion != null && !PackageVersion.Equals(other.PackageVersion)) { return(false); } if (PackageName != null && !PackageName.Equals(other.PackageName)) { return(false); } return(true); }
private async Task PurgeBackups(SourceFolder sf) { var numberToKeep = 5; if (sf.Backups.Count() > numberToKeep) { var toDelete = sf.Backups.OrderByDescending(x => x.ScheduledOn).Skip(numberToKeep).ToArray(); foreach (var b in toDelete) { try { if (File.Exists(b.FullPath)) { db.Backups.Remove(b); await db.SaveChangesAsync(); File.Delete(b.FullPath); log.LogInformation($"Backup {b.FullPath} purged"); } } catch (Exception xe) { log.LogError(xe, $"File purge failed: {b.FullPath}"); } } } }
public async Task <SourceFolder> AddSourceFolderAsync(SourceFolder sourceFolder) { var request = _mapper.Map <SourceFolderCreateRequest>(sourceFolder); var result = await _sourceFolders.CreateAsync(sourceFolder.CollectionId, request); return(_mapper.Map <SourceFolder>(result)); }
private async Task ProcessSourceFolder( OversawCollection oversawCollection, SourceFolder collectionSourceFolder) { using var loggerScope = _logger.BeginScope( "Looking at {SourceFolderPath}...", collectionSourceFolder.Path); var newFiles = await _sourceFolderService.GetNewFiles(collectionSourceFolder); if (!newFiles.Any()) { return; } _logger.LogInformation("{NewFilesCount} new files found", newFiles.Count); var movedFiles = await MoveFiles(newFiles, oversawCollection); await _dbStateService.SaveChanges(); _logger.LogInformation("{NewFilesSavedCount} files saved", movedFiles.Count); await movedFiles.Select(x => _remoteCommandService.SaveTags(x.FileId, x.MovedInformation.SourceTags)) .WhenAll(); await movedFiles .Select( x => _remoteCommandService.UpdateMetadataRequest(x.FileId, x.MovedInformation.SystemFile.Md5)) .WhenAll(); _logger.LogDebug("Update metadata requests are sent"); }
private async Task AddFolderSource(DateTimeOffset configuredOn, FolderSource fs) { var folder = fs.Folder.ToLower(); var sf = await db.SourceFolders.SingleOrDefaultAsync(x => x.FullPath == folder); if (sf != null && sf.DisplayName != fs.DisplayName) { log.LogError($"Source folder {folder} already exists in the database: display name {sf.DisplayName}"); } else { sf = await db.SourceFolders.SingleOrDefaultAsync(x => string.Compare(x.DisplayName, fs.DisplayName, true) == 0); if (sf == null) { sf = new SourceFolder { BackupEnabled = false, DisplayName = fs.DisplayName, //Path = String.Empty, FullPath = folder, ScheduledTime = 3, Type = fs.Type }; await db.SourceFolders.AddAsync(sf); } else { sf.FullPath = fs.Folder.ToLower(); sf.Type = fs.Type; } sf.ConfiguredOn = configuredOn; await db.SaveChangesAsync(); } }
private static IReadOnlyCollection <string> GetTags(SourceFolder sourceDirectory, FileInfo fileInfo) { var sourcePathEntries = GetPathParts(new DirectoryInfo(sourceDirectory.Path)); var filePathEntries = GetPathParts(fileInfo); return(filePathEntries.Except(sourcePathEntries).ToArray()); }
private void FileSearch(string folder, string pattern) { if (Path.GetFileName(folder).IndexOf(pattern, StringComparison.OrdinalIgnoreCase) >= 0) { sDirs.Add(folder); } // Get files string[] files = Directory.GetFiles(folder).Where(x => (new FileInfo(x).Attributes & FileAttributes.Hidden) == 0 && Path.GetFileName(x).IndexOf(pattern, StringComparison.OrdinalIgnoreCase) >= 0 && SourceFolder.IsSupportedFile(x) ).ToArray(); // Add file if file name contains pattern foreach (string file in files) { sFiles.Add(file); } // Get directories string[] dirs = Directory.GetDirectories(folder).Where(x => (new DirectoryInfo(x).Attributes & FileAttributes.Hidden) == 0 ).ToArray(); // Jump into sub directory foreach (string dir in dirs) { FileSearch(dir, pattern); } }
private async Task <MoveInformation?> PrepareMove(SourceFolder sourceFolder, SystemFile systemFile) { var fileInfo = systemFile.File; if (!_fileService.IsFileReady(fileInfo)) { _logger.LogWarning("File is not ready or was removed"); return(null); } var moveInformation = new MoveInformation(systemFile); moveInformation.MoveProblem = await FindProblems(sourceFolder, systemFile); if (sourceFolder.ShouldAddTagFromFilename) { moveInformation.SourceTags.AddRange(_sourceTagsProvider.GetTagsFromName(fileInfo)); } if (sourceFolder.ShouldCreateTagsFromSubfolders) { moveInformation.SourceTags.AddRange(_sourceTagsProvider.GetTagsFromPath(sourceFolder, fileInfo)); } return(moveInformation); }
public override int GetHashCode() { int hashcode = Type.GetHashCode(); if (SourceFolder != null) { hashcode += SourceFolder.GetHashCode(); } if (SourceRelPath != null) { hashcode += SourceRelPath.GetHashCode(); } if (PackageName != null) { hashcode += PackageName.GetHashCode(); } if (PackageVersion != null) { hashcode += PackageVersion.GetHashCode(); } if (GitUrl != null) { hashcode += GitUrl.GetHashCode(); } if (GitBranch != null) { hashcode += GitBranch.GetHashCode(); } return(hashcode); }
private static void PrintCalls(SourceFolder folder, TextWriter output) { output.WriteLine("Call File Name, Caller Name, Call Line Number, Call Column Number, Callee Name, Callee Definition File Name, Callee Definition Line Number"); foreach (var call in Queries.GetAllCalls(folder)) { var caller = call.ParentScope.GetParentScopesAndSelf <NamedScope>().FirstOrDefault(); string callerName = (caller == null ? String.Empty : caller.Name); string callInfo = String.Join(",", Q(call.Location.SourceFileName), Q(callerName), Q(call.Location.StartingLineNumber.ToString()), Q(call.Location.StartingColumnNumber.ToString()), Q(call.Name) ); var matchingMethods = call.FindMatches(); if (matchingMethods.Any()) { foreach (var method in matchingMethods) { foreach (var location in method.Locations) { string methodInfo = String.Join(",", Q(location.SourceFileName), Q(location.StartingLineNumber.ToString())); output.WriteLine("{0},{1}", callInfo, methodInfo); } } } else { output.WriteLine("{0},,", callInfo); } } }
private static void PrintMethods(SourceFolder folder, TextWriter output) { output.WriteLine("File Name,Line Number,Method Name, Method Signature"); foreach (var method in Queries.GetAllMethods(folder)) { output.WriteLine("{0},{1},{2},{3}", Q(method.PrimaryLocation.SourceFileName), Q(method.PrimaryLocation.StartingLineNumber.ToString()), Q(method.Name), Q(method.ToString())); } }
public async Task <IReadOnlyCollection <MoveInformation> > GetNewFiles(SourceFolder forSourceFolder) { if (forSourceFolder == null) { throw new ArgumentNullException(nameof(forSourceFolder)); } var extensions = forSourceFolder.SupportedExtensions; var directoryInfo = new DirectoryInfo(forSourceFolder.Path); if (!directoryInfo.Exists) { return(Array.Empty <MoveInformation>()); } var files = _fileService.GetFiles(directoryInfo, extensions) .OrderBy(x => x.LastWriteTimeUtc) .ToList(); var uniqueFiles = files.DistinctBy(x => x.FullName).ToList(); if (files.Count != uniqueFiles.Count) { _logger.LogWarning("{DuplicatesCount} duplicates received", files.Count - uniqueFiles.Count); } var newFiles = await FilterExistingFilePaths(forSourceFolder.CollectionId, uniqueFiles); var systemFiles = newFiles.Select(x => CreateSystemFile(x)); var result = new List <MoveInformation>(); foreach (var systemFile in systemFiles) { var prepared = await PrepareMove(forSourceFolder, systemFile); if (prepared == null) { continue; } var duplicate = result.FirstOrDefault(x => x.SystemFile.Md5 == prepared.SystemFile.Md5); if (duplicate != null) { _logger.LogWarning( "Duplicate files in source folder: {File}, {DuplicateFile}", duplicate.SystemFile.File.FullName, prepared.SystemFile.File.FullName); continue; } result.Add(prepared); } return(result); }
private void Copying_Function(string [] SourceFolders, string Destination) { var File_Extentions = new List <string> { ".lnk", ".cab", ".CAB", ".sig", ".bmp", ".bin", ".lst", ".exe", ".upg" }; IEnumerable <string> SWFiles; Drive_Worker.ReportProgress(0, Message_Status.COPYING); bool errorStatus_temp = true; foreach (string SourceFolder in SourceFolders) { SWFiles = Directory.GetFiles(SourceFolder.Replace("\r", ""), "*.*", SearchOption.AllDirectories) .Where(s => File_Extentions.Contains(Path.GetExtension(s))); string[] Destination_Files = new string[SWFiles.Count()]; string[] Source_Files = new string[SWFiles.Count()]; int j = 0; foreach (string File_Path in SWFiles) { if (CheckSumTools.Check_Valid_CheckSum(File_Path)) { File.Copy(File_Path, Destination + Path.GetFileName(File_Path), true); Destination_Files[j] = Destination + Path.GetFileName(File_Path); Source_Files[j] = File_Path; } else { Drive_Worker.ReportProgress(0, Message_Status.ERROR_HASHING); errorStatus_temp = false; break; } if (Drive_Worker.CancellationPending) { errorStatus_temp = false; break; } j++; } if (!CheckSumTools.Check_Valid_CheckSum_Folders(Destination_Files, Source_Files)) { Drive_Worker.ReportProgress(0, Message_Status.ERROR_CORRUPTED); errorStatus_temp = false; break; } } if (!errorStatus_temp == false) { Drive_Worker.ReportProgress(0, Message_Status.COMPLETE); } }
public async Task ReadAndWriteFileTest() { // Read text file await SourceFolder.GetFiles(o).TransForm().WriteTextFiles(); // Create TextFileInfo // read lines and create TextFile // write lines to new destination file Assert.Pass(); }
private void btnExport_Click(object sender, RoutedEventArgs e) { // check input first if (string.IsNullOrEmpty(SourceFolder.Text)) { MessageBox.Show("Please select source folder!"); SourceFolder.Focus(); return; } if (Directory.Exists(SourceFolder.Text) == false) { MessageBox.Show("Source folder does not exist!"); SourceFolder.Focus(); return; } if (string.IsNullOrEmpty(TargetFolder.Text)) { MessageBox.Show("Please select target folder!"); TargetFolder.Focus(); return; } string targetFolder = TargetFolder.Text; if (Directory.Exists(targetFolder) == false) { Directory.CreateDirectory(targetFolder); } // find all rvt files including sub directories var files = Directory.EnumerateFiles(SourceFolder.Text, "*.rvt", SearchOption.AllDirectories); int count = files.Count(), success = 0; double curStep = 0, current = 0, tempVal; foreach (var f in files) { if (exportOneFile(f, targetFolder)) { success++; } current++; // show progress when more than 5 percent tempVal = current * 100 / count; if (tempVal - 5 > curStep) { curStep = tempVal; progressBar.Value = curStep; RAPWPF.WpfApplication.DoEvents(); } } progressBar.Value = 100; RAPWPF.WpfApplication.DoEvents(); // show summary information MessageBox.Show("Export " + success + " files successfully, " + (count - success) + " files failed."); Close(); }
public async Task <SourceFolder> UpdateSourceFolderAsync(SourceFolder sourceFolder) { if (!sourceFolder.Id.HasValue) { throw new ArgumentException("Can't update new collection.", nameof(sourceFolder)); } var request = _mapper.Map <SourceFolderCreateRequest>(sourceFolder); var result = await _sourceFolders.UpdateAsync(sourceFolder.CollectionId, sourceFolder.Id.Value, request); return(_mapper.Map <SourceFolder>(result)); }
/// <summary> /// Backing up one folder /// </summary> /// <param name="itemsProgress"></param> /// <returns></returns> public async Task BackupOneDirAsync(string destinationPath, SourceFolder sourceFolder, BackupStatus backupStatus) { string source = sourceFolder.FolderInfo.FullPath; string dest = destinationPath; string folderName = sourceFolder.FolderInfo.Name; IProgress <string> stateProgress = backupStatus.StateProgress as IProgress <string>; IProgress <ProgressionItemsReport> itemsProgress = backupStatus.ItemsProgress as IProgress <ProgressionItemsReport>; if (Helpers.CreateDirectoryIfNotExists(dest)) { stateProgress.Report($"Created new folder {dest}"); } int count = 0; // Handling the top directories foreach (var src in Directory.GetDirectories(source)) { string name = Helpers.ExtractFileFolderNameFromFullPath(src); // Refactor slashes string dst = $"{destinationPath}\\{name}"; stateProgress.Report($"Start backing up {src} to { dst} {Environment.NewLine}"); await Task.Run(() => { Backup(src, dst, backupStatus); }); stateProgress.Report($"End backing up {src} to { dst} {Environment.NewLine}"); count++; itemsProgress.Report(new ProgressionItemsReport { ItemsCompletedCounter = count * 100 / sourceFolder.FolderInfo.ItemsCount, ItemsRemainingCounter = sourceFolder.FolderInfo.ItemsCount - count }); } // Handling the top files foreach (var file in Directory.GetFiles(source)) { BackupFile(dest, file, backupStatus); count++; itemsProgress.Report(new ProgressionItemsReport { ItemsCompletedCounter = count * 100 / sourceFolder.FolderInfo.ItemsCount, ItemsRemainingCounter = sourceFolder.FolderInfo.ItemsCount - count }); } string successMessage = $"Backing up from {source} to {dest} have been completed successfuly!"; stateProgress.Report(successMessage); ReportFile.WriteToLog(successMessage); }
static void Main(string[] args) { Parser.Default.ParseArguments <Options>(args) .WithParsed <Options>(async o => { ConsolePrint.Welcome(o.Quiet); await Setup.Structure(o); SourceFolder.GetFiles(o).TransForm(); await foreach (var textFile in SourceFolder.GetFiles(o).TransForm()) { } }); }
public async Task AddSourceFolder(SourceFolder sourceFolder) { using (var db = new DataContext()) { await db.SourceFolders.AddAsync(sourceFolder); await db.SaveChangesAsync(); } await ReFillCache <Collection>(); OnCollectionChanged(); }
private void btnUpgrade_Click(object sender, RoutedEventArgs e) { // check input first if (string.IsNullOrEmpty(SourceFolder.Text)) { MessageBox.Show("Please select source folder!"); SourceFolder.Focus(); return; } if (Directory.Exists(SourceFolder.Text) == false) { MessageBox.Show("Source folder does not exist!"); SourceFolder.Focus(); return; } if (string.IsNullOrEmpty(TargetFolder.Text)) { MessageBox.Show("Please select target folder!"); TargetFolder.Focus(); return; } // make sure that the source folder and target folder don't overlap string sourceFolder = SourceFolder.Text.TrimEnd('\\'), targetFolder = TargetFolder.Text.TrimEnd('\\'); if (sourceFolder.IndexOf(targetFolder, StringComparison.OrdinalIgnoreCase) == 0 || targetFolder.IndexOf(sourceFolder, StringComparison.OrdinalIgnoreCase) == 0) { string extra = ""; if (sourceFolder.Length > targetFolder.Length) { extra = sourceFolder.Substring(targetFolder.Length); } else { extra = targetFolder.Substring(sourceFolder.Length); } if (extra.Length == 0 || extra[0] == '\\') { MessageBox.Show("Target folder cannot be a parent or child folder of source folder!"); TargetFolder.Focus(); return; } } // at least select one file type if (cbRvt.IsChecked == false && cbRfa.IsChecked == false) { MessageBox.Show("At least check one Revit file type!"); return; } upgradeFolder(sourceFolder, targetFolder, (cbRvt.IsChecked == true), (cbRfa.IsChecked == true)); }
public void SyncFolder(SourceFolder sourceFolder, GoogleFolder remoteFolder) { if (sourceFolder.Files != null) { foreach (var file in sourceFolder.Files) { if (!_googleDriveService.DoesFileExistInFolder(remoteFolder, file.FileName)) { try { var remoteFile = _googleDriveService.UploadFile(remoteFolder, file.FileName, file.FullLocation, file.MimeType); _log.Info("File {0} uploaded, google id: {1}", file.FullLocation, remoteFile.Id); } catch (Exception ex) { _log.Error(ex); } } else { _log.Info("File {0} already exists", file.FullLocation); } } } if (sourceFolder.Folders != null) { foreach (var childFolder in sourceFolder.Folders) { if (_googleDriveService.DoesFolderExistInFolder(remoteFolder, childFolder.FolderName)) { try { var childRemoteFolder = _googleDriveService.CreateFolder(remoteFolder, childFolder.FolderName); _log.Info("Folder {0} created, google id: {1}", childFolder.FullLocation, childRemoteFolder.Id); SyncFolder(childFolder, childRemoteFolder); } catch (Exception ex) { _log.Error(ex); } } else { _log.Info("Folder {0} already exists", childFolder.FullLocation); } } } }
public virtual string GetSourceBlock(bool useSymbols = false) { if (ParentFolder is BlocksOfflineFolder) { BlocksOfflineFolder blkFld = (BlocksOfflineFolder)ParentFolder; return(blkFld.GetSourceBlock(this, useSymbols)); } if (ParentFolder is SourceFolder) { SourceFolder blkFld = (SourceFolder)ParentFolder; return(blkFld.GetSource((S7ProjectSourceInfo)this)); } return(null); }
private async Task UpdateLocationTagsInSourceFolder(SourceFolder sourceFolder) { var allFiles = _fileService.GetFiles( new DirectoryInfo(sourceFolder.Path), sourceFolder.SupportedExtensions); _logger.LogInformation( "Updating location tags for {SourceFolder}, found {Count} new files", sourceFolder.Path, allFiles.Count); foreach (var file in allFiles) { var foundFiles = await _collectionFileRepository.SearchByQuery( new CollectionFilesQuery(
protected override void Execute(CodeActivityContext context) { try { filePath = ZipFile.Get(context); folderPath = SourceFolder.Get(context); pwd = Password.Get(context); folderArray = MultipleFolders.Get(context); this.DoZip(); } catch (Exception ex) { throw ex; } }
//-- FILE SEARCH public void SearchFiles(string s) { Searching = s.Length > 0; if (!Searching) { // Search done Invoke("HideProgress", 0.01f); SourceFolder.Initialize(); } else { // Reset results sDirs = new List <String> (); sFiles = new List <String> (); // Dispose current thread if (thread != null && thread.IsBusy) { thread.Abort(); // thread.Dispose (); } // Initalize thread thread = new BackgroundThread(); thread.WorkerSupportsCancellation = true; thread.DoWork += delegate { // Destroy elements MainThreadDispatcher.Instance().Enqueue(SourceFolder.DestroyAll); // Get search results GetResults(s); // Display search results MainThreadDispatcher.Instance().Enqueue(delegate { SourceFolder.Display(sDirs, sFiles, true); }); // Hide progress MainThreadDispatcher.Instance().Enqueue(HideProgress); }; // Run thread thread.RunWorkerAsync(); } }
public IEnumerable <GitreeStorageFileNode> GetRootDocuments(SourceFolder sourceFolder) { var initialDir = Info.GetDirectoryInfoFor(sourceFolder); var initialFolder = new GitreeStorageFolderNode(initialDir, null, Workspace); FoldersToVisit.Enqueue(initialFolder); return(GetCore().Values()); IEnumerable <Option <GitreeStorageFileNode> > GetCore() { while (FoldersToVisit.Count > 0) { var folder = FoldersToVisit.Dequeue(); yield return(VisitFolder(folder)); } } }
/// <summary> /// Apply changes made to the monitored folders : settings + folder manager /// by scanning through all datagridview rows. /// /// TO IMPROVE /// USE DATABINDING /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ApplyFolderSettingsBox_Click(object sender, EventArgs e) { SourceFolder Streamdir; DataGridViewRow row = new DataGridViewRow(); string tmpstr = ""; bool appliedchangesonlyfolders = true;//Melek bool nochangesappliedsourcefolder = true; //Melek bool nochangesappliedresfolder = true;//Melek bool nochangesappliedrepfolder = true;//Melek // go through each folder in the list of folder for (int j = 0; j < StreamFoldersBox.Rows.Count; j++) // When the new Priority values are selected set priority values { row = StreamFoldersBox.Rows[j]; if ((string)row.Cells[5].Value == "1-Hot") //Set Priority Values and Hot - Melek { row.Cells[3].Value = 0; row.Cells[2].Value = true; //hot true } else if ((string)row.Cells[5].Value == "2-High") { row.Cells[3].Value = 64; row.Cells[2].Value = false; //hot false } else if ((string)row.Cells[5].Value == "3-Medium") { row.Cells[3].Value = 128; row.Cells[2].Value = false; //hot false } else if ((string)row.Cells[5].Value == "4-Low") { row.Cells[3].Value = 255; row.Cells[2].Value = false; //hot false } QAFolder qaf = new QAFolder((string)row.Cells[1].Value, "XML source folder", FolderType.SourceFolder); Streamdir = new SourceFolder(qaf, (bool)row.Cells[2].Value, Convert.ToInt16(row.Cells[3].Value), (string)row.Cells[4].Value, (string)row.Cells[5].Value); // Streamdir = new SourceFolder(qaf, Convert.ToInt16(row.Cells[3].Value), (string)row.Cells[4].Value, (string)row.Cells[5].Value); // check each folder in the GUI with the actual list of source folders // and update it if a difference is found if (qatool.EditSourceFolder(Streamdir)) tmpstr += " " + Streamdir.path + "\n"; } if (tmpstr != "") { tmpstr = "Applied changes to the following folders:\n" + tmpstr + "\n" + " NOTE: These changes will be applied only to the jobs to be processed on the Process Tab, not to the completed jobs on the Review and Results Tabs."; //Melek - comment is updated MessageBox.Show(tmpstr); Global.log(tmpstr); appliedchangesonlyfolders = false;//Melek } #region resultfolderconfig //enter results folder info - Melek string nf = ResDirTextBox.Text; QAFolder newfolder = new QAFolder(); if (nf == ""||(!Directory.Exists(nf))) { newfolder = new QAFolder(nf, "Local results folder", FolderType.ResultFolder); if (!qatool.SetNewResDir(newfolder)) { nf = newfolder.path; ResDirTextBox.Text=nf; } } try { if (nf.EndsWith("\\")) newfolder = new QAFolder(nf, "Local results folder", FolderType.ResultFolder); else newfolder = new QAFolder(nf + "\\", "Local results folder", FolderType.ResultFolder); if (qatool.SetNewResDir(newfolder)) { MessageBox.Show("Results folder changed to " + newfolder.path); nochangesappliedresfolder = false; } } catch (Exception ex) { Global.log("Error while changing to a new result folder.\n" + ex); } #endregion resultfolderconfig #region ReportsConfig - Melek if (RepDirTextBox.Text == "") { MessageBox.Show("Reports Folder section can not be empty, please enter a folder path to save results."); if (qaClass.settings.ReportsFolder == "") { RepDirTextBox.Text = "Set the folder where the pdf reports will be stored"; } else { RepDirTextBox.Text = qaClass.settings.ReportsFolder; } } else if (RepDirTextBox.Text != "Set the folder where the pdf reports will be stored\\" && RepDirTextBox.Text != "Set the folder where the pdf reports will be stored")//MElek { if (!Directory.Exists(RepDirTextBox.Text)) { MessageBox.Show("Directory \"" + RepDirTextBox.Text + "\" does not exist!"); if (qaClass.settings.ReportsFolder != null) { RepDirTextBox.Text = qaClass.settings.ReportsFolder; //Melek } } else { if (!RepDirTextBox.Text.EndsWith("\\")) { RepDirTextBox.Text = RepDirTextBox.Text + "\\"; } if (qatool.SetNewRepDir(RepDirTextBox.Text)) { nochangesappliedrepfolder = false; MessageBox.Show("Reports folder changed to " + RepDirTextBox.Text); } } } #endregion Reportconfig if (nochangesappliedsourcefolder && nochangesappliedresfolder && nochangesappliedrepfolder && appliedchangesonlyfolders && !reportsfolderchangedtemp) //no changes has done MessageBox.Show("No changes applied."); }
/// <summary> /// Dialog box to select a folder to monitor /// </summary> private void AddStreamDir() { try { string folder; FolderBrowserDialog fnd = new FolderBrowserDialog(); // fnd.ShowNewFolderButton = false; //Melek //fnd.RootFolder fnd.Description = "Select a folder to monitor"; if (fnd.ShowDialog() == DialogResult.OK) { folder = fnd.SelectedPath; } // else if ok was not clicked else { return ; } //#region NewDialog -Melek //OpenFileDialog fdlg = new OpenFileDialog(); //fdlg.Title = "Select a folder to monitor"; //fdlg.InitialDirectory = @"c:\"; //fdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"; //fdlg.FilterIndex = 2; //fdlg.RestoreDirectory = true; //if (fdlg.ShowDialog() == DialogResult.OK) //{ // // textBox1.Text = fdlg.FileName; //} //#endregion new dialog // The stream monitor thread needs to know the new streamdir try { SourceFolder sfolder = new SourceFolder(folder, "Monitored Folder", false, 128, "default", "3-Medium"); //Hot and Priorityname added - Melek //SourceFolder sfolder = new SourceFolder(folder, "Monitored Folder", 128, "default"); qatool.AddNewSourceFolder(sfolder); } catch (Exception ex) { MessageBox.Show("Error setting new monitored folder\n" + ex); } } catch (Exception ex) { MessageBox.Show("Choose monitored folder exception\n" + ex); } }