/// ------------------------------------------------------------------------------------ /// <summary> /// Reads a file for text tokens. /// </summary> /// <param name="fileName">Name of the file.</param> /// <returns>tokens located in the file</returns> /// ------------------------------------------------------------------------------------ private List <TextTokenSubstring> ReadFile(string fileName) { if (!File.Exists(fileName)) { return(null); } List <TextTokenSubstring> tokens; try { m_fileData = File.ReadAllLines(fileName); NormalizeFileData(); var data = new TextFileDataSource(m_scrChecksDllFile, m_checkToRun == CheckType.Punctuation ? "PunctuationCheck" : "CharactersCheck", m_fileData, ResourceHelper.GetResourceString("kstidFileLineRef"), m_chkParams, CharacterCategorizer); tokens = data.GetReferences(); } catch (Exception e) { MessageBox.Show(string.Format(FwCoreDlgs.kstidNonUnicodeFileError, e.Message), m_app.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); } return(tokens); }
protected override void ModifyCore(string method, string args, AttivioSearchVisual liveNode) { string[] rows = args.Split(new char[] { ',' }); data.Add(rows); var max = 0; foreach (string[] rs in data) { if (rs.Length > max) { max = rs.Length; } } StreamWriter writer = new StreamWriter(File.Open(AttivioSearchAddIn.DataFile, FileMode.Create), Encoding.UTF8); for (var i = 0; i < max; i++) { List <string> line = new List <string>(); foreach (string[] cell in data) { if (i < cell.Length) { line.Add(cell[i].Replace(";", ";").Replace(",", ",")); } else { line.Add(string.Empty); } } string lineString = String.Join(",", line.ToArray()); writer.WriteLine(lineString); } writer.Close(); TextFileDataSource dataSource = new TextFileDataSource(File.OpenRead(AttivioSearchAddIn.DataFile)); var document = liveNode.Visual.Context.GetService <Document>(); if (document.Data.Tables.Contains("CognitiveSearch")) { document.Data.Tables["CognitiveSearch"].ReplaceData(dataSource); } else { document.Data.Tables.Add("CognitiveSearch", dataSource); } }