private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { importLog.Log("selindexchanged"); dsList.Items.Clear(); using (ImportEngine engine = new ImportEngine()) { engine.Load(comboBox1.Text); cbEndpoints.Items.Clear(); cbEndpoints.Items.Add(String.Empty); foreach (var item in engine.Endpoints) { cbEndpoints.Items.Add(item.Name); } cbPipeLines.Items.Clear(); cbPipeLines.Items.Add(String.Empty); foreach (var item in engine.Pipelines) { cbPipeLines.Items.Add(item.Name); } uiFromFlags(engine); txtMaxRecords.Text = engine.MaxAdds.ToString(); txtMaxEmits.Text = engine.MaxEmits.ToString(); foreach (var ds in engine.Datasources) { dsList.Items.Add(ds.Name, ds.Active); } } }
public void TestImports() { File.Delete(newDataRoot + "cmd_out.txt"); //this is needed because the add on the ds/_start has no value and gets ignored ImportEngine eng = new ImportEngine(); eng.Load(root + "import.xml"); var report = eng.Import("json,jsoncmd,tika_raw,tika_sort_title,tika_undup_title"); Console.WriteLine(report); Assert.AreEqual(null, report.ErrorMessage); CheckFiles("cmd_out.txt"); CheckFiles("json_out.txt"); CheckFiles("tika_raw.txt"); CheckFiles("tika_sort_title.txt"); CheckFiles("tika_undup_title.txt"); Assert.AreEqual(5, report.DatasourceReports.Count); int i = -1; checkDataSourceStats(report.DatasourceReports[++i], 5, 5);//The string value will not be added, bcause its emitted as 'record'. It is 5/5 because there are 2 EP's. Maybe we need to do something for the string value... checkDataSourceStats(report.DatasourceReports[++i], 5, 5); checkDataSourceStats(report.DatasourceReports[++i], 10, 10); checkDataSourceStats(report.DatasourceReports[++i], 10, 10); checkDataSourceStats(report.DatasourceReports[++i], 10, 3); }
public void TestCommands() { File.Delete(newDataRoot + "cmd-out.txt"); ImportEngine eng = new ImportEngine(); eng.Load(root + "import.xml"); var report = eng.Import("jsoncmd"); Assert.AreEqual(1, report.DatasourceReports.Count); Assert.AreEqual(null, report.ErrorMessage); var dsReport = report.DatasourceReports[0]; Console.WriteLine("Report: {0}", dsReport); Assert.AreEqual(5, dsReport.Emitted); Assert.AreEqual(4, dsReport.Added); CheckFiles("cmd-out.txt"); }
public ImportReport Run(_ImportFlags flags, String switches, String xml, String[] activeDS, int maxAdds, int maxEmits) { try { using (ImportEngine engine = new ImportEngine()) { engine.Switches = switches; engine.ImportFlags = flags; engine.Load(xml); engine.MaxAdds = maxAdds; engine.MaxEmits = maxEmits; return(engine.Import(activeDS)); } } catch (Exception e) { Logs.ErrorLog.Log(e); throw new Exception(e.Message); } }
public void TestProviders() { Console.WriteLine(root); using (ImportEngine eng = new ImportEngine()) { eng.Load(root + "providers.xml"); var mainCtx = new PipelineContext(eng); PipelineContext ctx = new PipelineContext(mainCtx, eng.Datasources[0], new DatasourceReport(eng.Datasources[0])); XmlHelper xml = new XmlHelper(root + "providers.xml"); using (FileStream actual = new FileStream(root + "actual.txt", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite, 4096)) { using (TextWriter w = actual.CreateTextWriter()) { foreach (XmlNode node in xml.SelectSingleNode("tests").ChildNodes) { if (node.NodeType != XmlNodeType.Element) { continue; } RootStreamDirectory p = new RootStreamDirectory(ctx, node); dumpProvider(w, p, ctx, node.LocalName); } w.Flush(); byte[] exp = File.ReadAllBytes(root + "expected.txt"); actual.Position = 0; byte[] act = actual.ReadAllBytes(); Assert.AreEqual(exp.Length, act.Length); for (int i = 0; i < exp.Length; i++) { Assert.AreEqual(exp[i], act[i]); } } } } }
private static int runAsConsole(String[] args) { try { bool b = Bitmanager.Core.ConsoleHelpers.AttachConsole(); if (!b) { b = Bitmanager.Core.ConsoleHelpers.AllocConsole(); } } catch { } try { Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; var cmd = new CommandLineParms(args); if (cmd.NamedArgs.ContainsKey("?") || cmd.NamedArgs.ContainsKey("help")) { goto WRITE_SYNTAX; } String responseFile = cmd.NamedArgs.OptGetItem("resp"); if (responseFile != null) { if (cmd.Args.Count != 0) { goto WRITE_SYNTAX_ERR; } cmd = new CommandLineParms(responseFile); } _ImportFlags flags = Invariant.ToEnum <_ImportFlags>(cmd.NamedArgs.OptGetItem("flags"), _ImportFlags.UseFlagsFromXml); int maxAdds = Invariant.ToInt32(cmd.NamedArgs.OptGetItem("maxadds"), -1); int maxEmits = Invariant.ToInt32(cmd.NamedArgs.OptGetItem("maxemits"), -1); if (cmd.Args.Count == 0) { goto WRITE_SYNTAX_ERR; } using (ImportEngine eng = new ImportEngine()) { eng.MaxAdds = maxAdds; eng.MaxEmits = maxEmits; eng.ImportFlags = flags; String[] dsList = new String[cmd.Args.Count - 1]; for (int i = 1; i < cmd.Args.Count; i++) { dsList[i - 1] = cmd.Args[i]; } eng.Load(cmd.Args[0]); eng.Import(dsList.Length == 0 ? null : dsList); } return(0); WRITE_SYNTAX_ERR: logError("Invalid commandline: {0}", Environment.CommandLine); WRITE_SYNTAX: logError(""); logError("Syntax: <importxml file> [list of datasources] [/flags:<importflags>] [/maxadds:<number>] [/maxemits:<number>] [/$$xxxx$$:<value>"); logError(" or: /resp:<responsefile> with 1 option per line"); return(12); } catch (Exception e) { logError("Error: {0}\r\nType: {1}\r\nStack:\r\n{2}", e.Message, e.GetType().FullName, e.StackTrace); return(12); } }