Exemplo n.º 1
0
 public SearchFightController(IQueryMaker queryMaker)
 {
     if (queryMaker == null)
     {
         throw new ArgumentNullException("queryMaker");
     }
     this.queryMaker = queryMaker;
 }
Exemplo n.º 2
0
 public ReadTask(PerfRunData runData)
     : base(runData)
 {
     if (WithSearch)
     {
         queryMaker = GetQueryMaker();
     }
     else
     {
         queryMaker = null;
     }
 }
Exemplo n.º 3
0
 protected ReadTask(PerfRunData runData) // LUCENENET: CA1012: Abstract types should not have constructors (marked protected)
     : base(runData)
 {
     if (WithSearch)
     {
         queryMaker = GetQueryMaker();
     }
     else
     {
         queryMaker = null;
     }
 }
Exemplo n.º 4
0
        private int Process(string mode)
        {
            try
            {
                Directory.CreateDirectory(_options.OutputDirectory);

                ExcelReader excelReader = new ExcelReader(_options.ReadEmptyRecords, _options.WorksheetsToRead?.ToArray());

                ValueRenderer valueRenderer = new ValueRenderer(_options.NullReplacements?.ToArray());

                IQueryMaker queryMaker = QueryMakerFactory.Create(mode, valueRenderer);

                TableScriptGenerator tableScriptGenerator = new TableScriptGenerator(queryMaker);

                IEnumerable <Table> tables = excelReader.Read(_options.InputFile);

                foreach (Table table in tables)
                {
                    string filePath = Path.Combine(_options.OutputDirectory, table.Name + ".sql");
                    Write($"writing {filePath} ...");

                    if (table.Records.Any())
                    {
                        using (Script script = tableScriptGenerator.GenerateTableScript(table))
                        {
                            using (FileStream fileStream = File.Create(filePath))
                            {
                                script.Content.CopyTo(fileStream);
                                WriteLine(" done");
                            }
                        }
                    }
                    else
                    {
                        WriteLine(" empty (skipped)");
                    }
                }

                return(0);
            }
            catch (Exception ex)
            {
                Error.WriteLine($"Error: {ex.GetType().Name}");
                Error.WriteLine($"Error: {ex.Message}");
#if DEBUG
                Error.WriteLine(ex.StackTrace);
#endif
                return(1);
            }
        }
Exemplo n.º 5
0
        public void CanGenerateScripts()
        {
            IQueryMaker queryMakerSubstitute = Substitute.For <IQueryMaker>();

            queryMakerSubstitute.GenerateQuery(Arg.Any <ExcelToSQLScripts.Models.Record>()).Returns("random string\n");

            TableScriptGenerator tableScriptGenerator = new TableScriptGenerator(queryMakerSubstitute);

            Table table = Utils.GetTable(2);

            using (Script script = tableScriptGenerator.GenerateTableScript(table))
            {
                script.Name.Should().Be("Employees");
                script.Content.Should().NotBeNull();

                StreamReader streamReader = new StreamReader(script.Content);
                string       content      = streamReader.ReadToEnd();

                content.Should().Be("random string\nrandom string\n");
            }
        }
 public TableScriptGenerator(IQueryMaker queryMaker)
 {
     _queryMaker = queryMaker;
 }