private void Main_Run_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { try { button7.Enabled = true; searchSubs.Enabled = true; button5.Enabled = true; button9.Enabled = true; button2.Enabled = false; folderPath.ReadOnly = false; button11.Enabled = true; button12.Enabled = true; savePath.ReadOnly = false; fileType.Enabled = true; fileType.Checked = false; UpdateProgressTextDelegate UpdateText = ProgressLabel; UpdateStatusTextDelegate UpdateStatus = StatusLabel; UpdateStatusProgressDelegate UpdateProgress = Progress; if (main.IsBusy) { Invoke(UpdateText, "Stopping.."); Invoke(UpdateStatus, "Stopping.."); } Invoke(UpdateText, "Complete."); Invoke(UpdateStatus, ""); Invoke(UpdateProgress, 0); string pages = servRef.GetPagesLeft(clientID, secret); label8.Text = "Pages left: " + pages; languages.Enabled = true; progressBar.Visible = false; folderPath.Text = ""; //reset away mode Kernel32.SetThreadExecutionState(Kernel32.EXECUTION_STATE.None | Kernel32.EXECUTION_STATE.None | Kernel32.EXECUTION_STATE.None); MessageBox.Show("Run Complete.", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { //assume worker closed MessageBox.Show("Oops. Something went wrong.", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public void StartTagging() { wndMainWindow = this.Owner as MainWindow; UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(pbProgress.SetValue); UpdateProgressTextDelegate updatePtDelegate = new UpdateProgressTextDelegate(txtResults.SetValue); double i = 0.0; int total = wndMainWindow.AudioEngine.Playlist.Count; pbProgress.Minimum = i; pbProgress.Maximum = total; string t = "Initializing..."; int idx = 0; int c = wndMainWindow.AudioEngine.Playlist.Count(); Database.Song[] temp = new Database.Song[c]; wndMainWindow.AudioEngine.Playlist.CopyTo(temp, 0); // can't modify the playlist if its the subject of the foreach, so we have to make a copy. foreach (Database.Song row in temp) { i++; t += "\n" + "Processing file " + i.ToString() + " of " + total.ToString() + " | " + row.Filename; Dispatcher.Invoke(updatePtDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { TextBox.TextProperty, t }); AudioEngine.Fingerprint(row); wndMainWindow.AudioEngine.Playlist.RemoveAt(idx); wndMainWindow.AudioEngine.Playlist.Insert(idx, row); Dispatcher.Invoke(updatePbDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, i }); idx++; } this.btnClose.IsEnabled = true; }
private void BtMakeArchive_OnClick(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(TbFeedback.Text)) { if (!MessageBox.ShowYesNo(ModPlusAPI.Language.GetItem(LangItem, "h75"))) { return; } } var updatePbDelegate = new UpdateProgressBarDelegate(ProgressBar.SetValue); var updatePtDelegate = new UpdateProgressTextDelegate(ProgressText.SetValue); if (!_filesToBind.Any(x => x.Selected)) { MessageBox.Show(ModPlusAPI.Language.GetItem(LangItem, "msg15"), MessageBoxIcon.Alert); return; } CreateArchive(); Dispatcher?.Invoke(updatePtDelegate, DispatcherPriority.Background, TextBlock.TextProperty, string.Empty); Dispatcher?.Invoke(updatePbDelegate, DispatcherPriority.Background, System.Windows.Controls.Primitives.RangeBase.ValueProperty, 0.0); }
private void CreateArchive() { // Create a new instance of our ProgressBar Delegate that points // to the ProgressBar's SetValue method. var updatePbDelegate = new UpdateProgressBarDelegate(ProgressBar.SetValue); var updatePtDelegate = new UpdateProgressTextDelegate(ProgressText.SetValue); // progress text Dispatcher?.Invoke(updatePtDelegate, DispatcherPriority.Background, TextBlock.TextProperty, ModPlusAPI.Language.GetItem(LangItem, "msg16")); // create temp folder var tmpFolder = Path.Combine(_dwgBaseFolder, "Temp"); if (!Directory.Exists(tmpFolder)) { Directory.CreateDirectory(tmpFolder); } // create base file with selected files items ProgressBar.Minimum = 0; ProgressBar.Maximum = _dwgBaseItems.Count; ProgressBar.Value = 0; // Соберем список файлов-источников чтобы проще их сверять var sourceFiles = new List <string>(); foreach (var fileToBind in _filesToBind) { if (!sourceFiles.Contains(fileToBind.SourceFile)) { sourceFiles.Add(fileToBind.SourceFile); } } var baseFileToArchive = new List <DwgBaseItem>(); for (var i = 0; i < _dwgBaseItems.Count; i++) { Dispatcher.Invoke(updatePtDelegate, DispatcherPriority.Background, TextBlock.TextProperty, ModPlusAPI.Language.GetItem(LangItem, "msg17") + ": " + i + "/" + _dwgBaseItems.Count); Dispatcher.Invoke(updatePbDelegate, DispatcherPriority.Background, System.Windows.Controls.Primitives.RangeBase.ValueProperty, (double)i); var dwgBaseItem = _dwgBaseItems[i]; if (sourceFiles.Contains(dwgBaseItem.SourceFile)) { if (!baseFileToArchive.Contains(dwgBaseItem)) { baseFileToArchive.Add(dwgBaseItem); } } } // save xml file var xmlToArchive = Path.Combine(tmpFolder, "UserDwgBase.xml"); DwgBaseHelpers.SerializerToXml(baseFileToArchive, xmlToArchive); if (!File.Exists(xmlToArchive)) { MessageBox.Show(ModPlusAPI.Language.GetItem(LangItem, "msg18"), MessageBoxIcon.Close); return; } // comment file var commentFile = CreateCommentFile(tmpFolder); // create zip _currentFileToUpload = Path.ChangeExtension(Path.Combine(tmpFolder, Path.GetRandomFileName()), ".zip"); if (File.Exists(_currentFileToUpload)) { File.Delete(_currentFileToUpload); } using (var zip = ZipFile.Open(_currentFileToUpload, ZipArchiveMode.Create)) { // create directories foreach (var fileToBind in _filesToBind.Where(x => x.Selected)) { zip.CreateEntryFromFile( fileToBind.FullFileName, Path.Combine(fileToBind.SubDirectory, fileToBind.FileName)); } // add xml file and delete him zip.CreateEntryFromFile(xmlToArchive, new FileInfo(xmlToArchive).Name); // add comment file if (!string.IsNullOrEmpty(commentFile) && File.Exists(commentFile)) { zip.CreateEntryFromFile(commentFile, new FileInfo(commentFile).Name); } } File.Delete(xmlToArchive); // show buttons BtMakeArchive.Visibility = Visibility.Collapsed; BtSeeArchive.Visibility = Visibility.Visible; BtDeleteArchive.Visibility = Visibility.Visible; BtUploadArchive.Visibility = Visibility.Visible; Dispatcher?.Invoke(updatePtDelegate, DispatcherPriority.Background, TextBlock.TextProperty, ModPlusAPI.Language.GetItem(LangItem, "msg19")); }
private void MultiChangePath_Accept_OnClick(object sender, RoutedEventArgs e) { if (MultiChangePath_Path.Text.Equals("Блоки/") | MultiChangePath_Path.Text.Equals("Чертежи/")) { ModPlusAPI.Windows.MessageBox.Show(ModPlusAPI.Language.GetItem(LangItem, "u25")); MultiChangePath_Path.Focus(); return; } var selectedItems = new List <DwgBaseItem>(); foreach (DwgBaseItemWithSelector item in MultiChangePath_LvItems.Items) { if (item.Selected) { selectedItems.Add(item.Item); } } if (!selectedItems.Any()) { ModPlusAPI.Windows.MessageBox.Show(ModPlusAPI.Language.GetItem(LangItem, "u26")); return; } if (!ModPlusAPI.Windows.MessageBox.ShowYesNo( ModPlusAPI.Language.GetItem(LangItem, "u27"), MessageBoxIcon.Question)) { return; } var updatePbDelegate = new UpdateProgressBarDelegate(ProgressBar.SetValue); var updatePtDelegate = new UpdateProgressTextDelegate(ProgressText.SetValue); ProgressBar.Minimum = 0; ProgressBar.Maximum = _dwgBaseItems.Count; ProgressBar.Value = 0; var index = 1; foreach (var dwgBaseItem in _dwgBaseItems) { foreach (var selectedItem in selectedItems) { if (dwgBaseItem.Equals(selectedItem)) { dwgBaseItem.Path = MultiChangePath_Path.Text; } } Dispatcher?.Invoke(updatePtDelegate, DispatcherPriority.Background, TextBlock.TextProperty, $"{ModPlusAPI.Language.GetItem(LangItem, "u24")}: {index}/{_dwgBaseItems.Count}"); Dispatcher?.Invoke(updatePbDelegate, DispatcherPriority.Background, System.Windows.Controls.Primitives.RangeBase.ValueProperty, (double)index); index++; } // was changed UserBaseChanged = true; // save DwgBaseHelpers.SerializerToXml(_dwgBaseItems, _userDwgBaseFile); DwgBaseHelpers.DeserializeFromXml(_userDwgBaseFile, out _dwgBaseItems); Dispatcher?.Invoke(updatePtDelegate, DispatcherPriority.Background, TextBlock.TextProperty, ModPlusAPI.Language.GetItem(LangItem, "u28")); ModPlusAPI.Windows.MessageBox.Show(ModPlusAPI.Language.GetItem(LangItem, "u28")); ClearProgress(); // refill MultiChangePath_FillData(); }
/// <summary> /// Заполнение окна данными. Делается методом для возможности повторного вызова после внесения изменений /// </summary> private void MultiChangePath_FillData() { var updatePbDelegate = new UpdateProgressBarDelegate(ProgressBar.SetValue); var updatePtDelegate = new UpdateProgressTextDelegate(ProgressText.SetValue); var cb = MultiChangePath_CbMainGroup; var tb = MultiChangePath_Path.Template.FindName("PART_EditableTextBox", MultiChangePath_Path) as TextBox; // remove events MultiChangePath_Path.TextInput -= Blocks_TbPath_OnTextInput; MultiChangePath_Path.PreviewTextInput -= Blocks_TbPath_OnPreviewTextInput; if (tb != null) { tb.TextChanged -= Blocks_TbPath_OnTextChanged; } MultiChangePath_Path.TextInput -= Drawings_TbPath_OnTextInput; MultiChangePath_Path.PreviewTextInput -= Drawings_TbPath_OnPreviewTextInput; if (tb != null) { tb.TextChanged -= Drawings_TbPath_OnTextChanged; } // fill cb with path var paths = new List <string>(); foreach (var dwgBaseItem in _dwgBaseItems) { if (!paths.Contains(dwgBaseItem.Path)) { paths.Add(dwgBaseItem.Path); } } if (cb.SelectedIndex == 0) // blocks { MultiChangePath_Path.Text = "Блоки/"; MultiChangePath_Path.TextInput += Blocks_TbPath_OnTextInput; MultiChangePath_Path.PreviewTextInput += Blocks_TbPath_OnPreviewTextInput; if (tb != null) { tb.TextChanged += Blocks_TbPath_OnTextChanged; } MultiChangePath_Path.ItemsSource = paths.Where(x => x.StartsWith("Блоки/")); // fill items MultiChangePath_LvItems.ItemsSource = null; var lst = new List <DwgBaseItemWithSelector>(); ProgressBar.Minimum = 0; ProgressBar.Maximum = _dwgBaseItems.Count; ProgressBar.Value = 0; var index = 1; foreach (var dwgBaseItem in _dwgBaseItems) { if (dwgBaseItem.IsBlock) { lst.Add(new DwgBaseItemWithSelector { Selected = false, Item = dwgBaseItem }); } Dispatcher?.Invoke(updatePtDelegate, DispatcherPriority.Render, TextBlock.TextProperty, $"{ModPlusAPI.Language.GetItem(LangItem, "u24")}: {index}/{_dwgBaseItems.Count}"); Dispatcher?.Invoke(updatePbDelegate, DispatcherPriority.Render, System.Windows.Controls.Primitives.RangeBase.ValueProperty, (double)index); index++; } MultiChangePath_LvItems.ItemsSource = lst; } if (cb.SelectedIndex == 1) // drawings { MultiChangePath_Path.Text = "Чертежи/"; MultiChangePath_Path.TextInput += Drawings_TbPath_OnTextInput; MultiChangePath_Path.PreviewTextInput += Drawings_TbPath_OnPreviewTextInput; if (tb != null) { tb.TextChanged += Drawings_TbPath_OnTextChanged; } MultiChangePath_Path.ItemsSource = paths.Where(x => x.StartsWith("Чертежи/")); // fill items MultiChangePath_LvItems.ItemsSource = null; var lst = new List <DwgBaseItemWithSelector>(); ProgressBar.Minimum = 0; ProgressBar.Maximum = _dwgBaseItems.Count; ProgressBar.Value = 0; var index = 1; foreach (var dwgBaseItem in _dwgBaseItems) { if (!dwgBaseItem.IsBlock) { lst.Add(new DwgBaseItemWithSelector { Selected = false, Item = dwgBaseItem }); } Dispatcher.Invoke(updatePtDelegate, DispatcherPriority.Background, TextBlock.TextProperty, $"{ModPlusAPI.Language.GetItem(LangItem, "u24")}: {index}/{_dwgBaseItems.Count}"); Dispatcher.Invoke(updatePbDelegate, DispatcherPriority.Background, System.Windows.Controls.Primitives.RangeBase.ValueProperty, (double)index); index++; } MultiChangePath_LvItems.ItemsSource = lst; } ClearProgress(); }
private void Main_Run_DoWork(object sender, DoWorkEventArgs e) { #region Set Up Run DataTable finishedRun = new DataTable(); finishedRun.Columns.Add("Digitised Text"); finishedRun.Columns.Add("Translated Text"); finishedRun.Columns.Add("Fields Found"); finishedRun.Columns.Add("Clauses Found"); Globals.dpi = GetConfiguration.GetConfigurationValueDPI(); Globals.meta = GetConfiguration.GetConfigurationValueMeta(); Globals.ocrType = GetConfiguration.GetConfigurationValueOCR(); strLineRemoval = GetConfiguration.GetConfigurationValueGrayScale(); if (Globals.ocrType.Equals("Microsoft Cloud")) { Globals.ocrType = "1"; } else if (Globals.ocrType.Equals("Google Cloud")) { Globals.ocrType = "2"; } else if (Globals.ocrType.Equals("AWS Textract")) { Globals.ocrType = "3"; } else { Globals.ocrType = "0"; } //Make sure thread does not send PC to sleep Kernel32.SetThreadExecutionState(Kernel32.EXECUTION_STATE.ES_CONTINUOUS | Kernel32.EXECUTION_STATE.ES_SYSTEM_REQUIRED | Kernel32.EXECUTION_STATE.ES_AWAYMODE_REQUIRED); string[] docList = null; if (fileType.Checked == false) { try { if (searchSubDirects == true) { docList = Directory.GetFiles(folderPath.Text.Trim(), "*.*", SearchOption.AllDirectories); } else { docList = Directory.GetFiles(folderPath.Text.Trim(), "*.*"); } } catch { MessageBox.Show("Unable to find Run directory..", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { if (Globals.files != null) { docList = Globals.files; } else { MessageBox.Show("Please choose some files..", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } docList = Array.FindAll(docList, isNotLockFile); if (!Directory.Exists(savePath.Text.Trim())) { MessageBox.Show("Unable to find Save directory..", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (docList.Length <= 0) { MessageBox.Show("Unable to find any files in the Run directory..", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Prepare Run string prepare = servRef.PrepareRun(clientID, secret, Globals.sqlCon); if (!prepare.ToUpper().Equals("SUCCESS")) { MessageBox.Show("Oops. Something went wrong.", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } #endregion string lastFile = docList[docList.Length - 1]; foreach (string file in docList) { UpdateStatusProgressDelegate UpdateProgress = Progress; UpdateProgressTextDelegate UpdateText = ProgressLabel; UpdateStatusTextDelegate UpdateStatus = StatusLabel; UpdatePagesTextDelegate UpdatePages = PagesLabel; bool convertedFile = false; string runFile = file; string tempFile = file; bool corruptFile = false; if (Path.GetExtension(file).ToUpper().Trim().Equals(".DOCX")) { Invoke(UpdateStatus, "Resaving Word Document as PDF"); try { //check for mixed media var wordApplication = new Microsoft.Office.Interop.Word.Application(); wordApplication.Visible = false; var document = wordApplication.Documents.Open(file, false, true); Guid strGuid = Guid.NewGuid(); //convert to pdf string tempPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); tempPath = Path.Combine(tempPath, "temps"); if (!Directory.Exists(tempPath)) { Directory.CreateDirectory(tempPath); } string tempFileName = Path.GetFileNameWithoutExtension(file); document.ExportAsFixedFormat(System.IO.Path.Combine(tempPath, strGuid + ".pdf"), WdExportFormat.wdExportFormatPDF); runFile = System.IO.Path.Combine(tempPath, strGuid + ".pdf"); convertedFile = true; // Close word wordApplication.Quit(); document = null; wordApplication = null; GC.Collect(); } catch (Exception exe) { if (wordWarning == false) { MessageBox.Show("Without Microsoft Word on this machine we will only be able to use the native text these types of document(.DOCX) document. To digitise any pictures in the document, please install Microsoft Word. Alternatively convert it to a .pdf and rerun Quill.", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Information); wordWarning = true; } } } #region Loop Files if (cancelMain == true) { break; } string fileName = Path.GetFileName(runFile); Invoke(UpdateProgress, 0); if (!string.IsNullOrEmpty(tempFile)) { Invoke(UpdateText, "Working on file: " + Path.GetFileName(tempFile)); } else { Invoke(UpdateText, "Working on file: " + fileName); } Invoke(UpdateStatus, "Transmitting File.."); #region Send File //Convert to Bytes FileInfo fi = new FileInfo(runFile); long numBytes = fi.Length; FileStream fs = new FileStream(runFile, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); byte[] fileArray = br.ReadBytes((int)numBytes); br.Close(); fs.Close(); fs.Dispose(); Invoke(UpdateStatus, "Transmitting"); //Transmit File Invoke(UpdateProgress, 10); if (cancelMain == true) { return; } string transmit = servRef.SaveClientFile(fileArray, runFile, clientID, secret); bool invalidTypeContinue = false; if (!transmit.ToUpper().Equals("SUCCESS")) { DialogResult type = MessageBox.Show("Oops. Quill Can't convert: " + runFile + " Would you like to continue?", "Quill", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (DialogResult.No == type) { cancelMain = true; break; } else { invalidTypeContinue = true; } } if (cancelMain == true) { break; } #endregion if (invalidTypeContinue == false) { #region Get File ID Invoke(UpdateStatus, "Get File ID"); string fileID = servRef.GetFileID(fileName, clientID, secret); Invoke(UpdateProgress, 20); #endregion #region Check file type Invoke(UpdateStatus, "Native Check.."); string native = servRef.NativeTextCheck(fileName, Globals.sqlCon, false, clientID, secret, fileID, Globals.meta, Globals.ignoreMeta); if (native.Contains("QuillException: Document Limit Reached")) { MessageBox.Show("Document Limit Reached. You must purchase a license to continue, please visit www.QuillDigital.co.uk", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Invoke(UpdateProgress, 30); //Digitise string fullText = string.Empty; #endregion #region Digitise if (native.ToUpper().Equals("TRUE")) { if (cancelMain == true) { break; } Invoke(UpdateStatus, "Getting Text.."); fullText = servRef.GetFullTextByID(fileID, clientID, secret); if (fullText.Contains("QuillException: Document Limit Reached")) { MessageBox.Show("Document Limit Reached. You must purchase a license to continue, please visit www.QuillDigital.co.uk", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } fullText = Regex.Replace(fullText, @"(\r\n){2,}", Environment.NewLine); Invoke(UpdateProgress, 40); } else { Invoke(UpdateStatus, "Digitising.."); try { if (cancelMain == true) { break; } Invoke(UpdateProgress, 40); string digitise = servRef.Digitise(fileName, fileID, clientID, secret, Globals.sqlCon, Globals.ocrType, strLineRemoval, Globals.dpi, "0"); if (digitise.Contains("QuillException: Document limit reached")) { MessageBox.Show("Document Limit Reached. You must purchase a license or more pages to continue, please visit www.QuillDigital.co.uk", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (digitise.Contains("File Corrupt- unable to convert")) { corruptFile = true; } } catch (Exception ex) { //wait here for retort } Invoke(UpdateProgress, 50); Invoke(UpdateStatus, "Getting Text.."); if (cancelMain == true) { break; } if (corruptFile == false) { fullText = servRef.GetFullTextByID(fileID, clientID, secret); if (fullText.Contains("QuillException: Document limit reached")) { MessageBox.Show("Document Limit Reached. You must purchase a license to continue, please visit www.QuillDigital.co.uk", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } fullText = Regex.Replace(fullText, @"(\r\n){2,}", Environment.NewLine); } else { fullText = "File Corrupt - unable to convert"; } } string clausesFound = string.Empty; string fields = string.Empty; string translated = string.Empty; #endregion if (corruptFile == false) { Invoke(UpdateProgress, 50); #region Translate //Translate if (!translationlang.ToUpper().Trim().Equals("NONE")) { Invoke(UpdateProgress, 60); Invoke(UpdateStatus, "Translating.."); if (cancelMain == true) { break; } translated = servRef.TranslateByFileID(clientID, secret, Globals.sqlCon, fileID, translationlang); if (translated.Contains("QuillException: Document Limit Reached")) { MessageBox.Show("Document Limit Reached. You must purchase a license to continue, please visit www.QuillDigital.co.uk", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } translated = Regex.Replace(translated, @"(\r\n){2,}", Environment.NewLine); } #endregion //extract fields #region Extract Fields if (extractFields.Checked == true) { if (cancelMain == true) { break; } Invoke(UpdateProgress, 70); Invoke(UpdateStatus, "Extracting Fields.."); if (cancelMain == true) { break; } fields = servRef.ExtractFieldsByFileID(fileID, fileName, clientID, secret, Globals.sqlCon, "0", GetConfiguration.GetConfigurationValueFields(), "0"); if (fields.Contains("QuillException: Document Limit Reached")) { MessageBox.Show("Document Limit Reached. You must purchase a license to continue, please visit www.QuillDigital.co.uk", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } fields = Regex.Replace(fields, @"(\r\n){1,}", Environment.NewLine); } #endregion if (cancelMain == true) { break; } #region Check Clauses if (clauses.Checked == true) { Invoke(UpdateProgress, 80); Invoke(UpdateStatus, "Extracting Clauses.."); string clausesOUT = GetConfiguration.GetConfigurationValueClauses(); DataTable dtclausesFound = servRef.CheckForClausesByFileID(clientID, secret, Globals.sqlCon, fileID, fileName, clausesOUT); if (clausesFound.Contains("QuillException: Document Limit Reached")) { MessageBox.Show("Document Limit Reached. You must purchase a license to continue, please visit www.QuillDigital.co.uk", "Quill", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (dtclausesFound.Rows.Count <= 0) { clausesFound = "No Clauses Found."; } else { clausesFound = string.Empty; foreach (DataRow row in dtclausesFound.Rows) { string tagOne = row["TagOne"].ToString(); if (string.IsNullOrEmpty(tagOne)) { tagOne = "Tag One not found.."; } string tagTwo = row["TagTwo"].ToString(); if (string.IsNullOrEmpty(tagTwo)) { tagTwo = "Tag Two not found.."; } string tagThree = row["TagThree"].ToString(); if (string.IsNullOrEmpty(tagThree)) { tagThree = "Tag Three not found.."; } string tagFour = row["TagFour"].ToString(); if (string.IsNullOrEmpty(tagFour)) { tagFour = "Tag Four not found.."; } string tagFive = row["TagFive"].ToString(); if (string.IsNullOrEmpty(tagFive)) { tagFive = "Tag Five not found.."; } string clauseFound = row["ClauseFound"].ToString(); string probablility = row["Probability"].ToString(); clausesFound = clausesFound + Environment.NewLine + tagOne + Environment.NewLine + tagTwo + Environment.NewLine + tagThree + Environment.NewLine + tagFour + Environment.NewLine + tagFive + Environment.NewLine + "Levenstein Distance: " + probablility + Environment.NewLine + Environment.NewLine; } } clausesFound = Regex.Replace(clausesFound, @"(\r\n){2,}", Environment.NewLine); //need to extract clauses } #endregion } #region NLP if (Globals.nlpAnns != null) { Invoke(UpdateProgress, 90); Invoke(UpdateStatus, "Running NLP.."); foreach (string anns in Globals.nlpAnns) { if (!string.IsNullOrEmpty(anns.Trim())) { Invoke(UpdateStatus, "Running " + anns + ".."); string nlpOUT = servRef.ProcessQuillNLP(fileID, anns.ToLower().Trim(), clientID, secret); } } } #endregion Invoke(UpdateProgress, 90); Invoke(UpdateStatus, "Writing Report.."); #region Write Report string xmlDoc = string.Empty; string xmlReport = servRef.GetReportByID(clientID, secret, fileID); if (string.IsNullOrEmpty(tempFile)) { xmlDoc = Path.GetFileNameWithoutExtension(file) + ".xml"; System.IO.File.WriteAllText(Path.Combine(savePath.Text, xmlDoc), xmlReport); } else { xmlDoc = Path.GetFileNameWithoutExtension(tempFile) + ".xml"; System.IO.File.WriteAllText(Path.Combine(savePath.Text, xmlDoc), xmlReport); } if (convertedFile == true) { File.Delete(runFile); } if (file.ToUpper().Trim().Equals(lastFile.ToUpper().Trim()) | tempFile.ToUpper().Trim().Equals(lastFile.ToUpper().Trim())) { break; } #endregion #endregion } string pages = servRef.GetPagesLeft(clientID, secret); Invoke(UpdatePages, "Pages left: " + pages); } return; }