public void GetHelp_With_Argument_Null_Should_Retrun_True() { string[] args = { null }; bool result = ExcelToSql.GetHelp(args); result.Should().BeTrue(); }
public void GetHelp_With_Arguments_go_Should_Retrun_False() { string[] args = { "go" }; bool result = ExcelToSql.GetHelp(args); result.Should().BeFalse(); }
public void GetHelp_With_Arguments_Dummy_Should_Retrun_True() { Fixture fixture = new Fixture(); var arg = fixture.Create("arg"); string[] args = { arg }; bool result = ExcelToSql.GetHelp(args); result.Should().BeTrue(); }
public void GetSqlStatements(ref ExcelToSql.ExcelToSqlService ExcelToSql) { ExcelToSql.SqlProcessParameters parameters = new ExcelToSql.SqlProcessParameters(); parameters.SqlStatement.SqlScript = "select * from dbo.tbl_SqlStatements order by Command, ProcessOrder"; parameters.SqlStatement.WorksheetName = rngp_SqlStatements.WorksheetName; parameters.SqlStatement.RangeName = rngp_SqlStatements.RangeName; var rn = rngp_SqlStatements.GetRange(); if (rn != null) { rn.Cells.ClearContents(); } ExcelToSql.GetCommand(parameters); }
public bool TestQuery(ref ExcelToSql.ExcelToSqlService ExcelToSql) { bool blOK; ExcelToSql.SqlProcessParameters parameters = new ExcelToSql.SqlProcessParameters(); parameters.SqlStatement.SqlScript = "select top (1) Id from dbo.tbl_SqlStatements"; try { ExcelToSql.ExecuteCommand(parameters); blOK = true; } catch (Exception) { blOK = false; throw; } return blOK; }
static void Main() { //wczytywanie danych ze strony string url = "https://danepubliczne.imgw.pl/api/data/synop"; JsonToDB jsonToDB = new JsonToDB(url); //wczytywanie danych z excela string excelFilepath = "C:/Users/dell/Desktop/les/2016_As(PM10)_24g.xlsx"; ExcelToSql excelToSql = new ExcelToSql(excelFilepath); DataProcessing dataProcessing = new DataProcessing(); // GetStringFromData getStringFromData = new GetStringFromData(); List <String> dataStringList = new List <string>(); List <String> dataStringList2 = new List <string>(); // tu cos nie dzial //dataString = getStringFromData.StringFromDatabase(); SqlReader sqlReader = new SqlReader(); SqlReader2 sqlReader2 = new SqlReader2(); dataStringList = sqlReader.getDataAS2016procString(); dataStringList2 = sqlReader2.getPogodaString(); System.Console.WriteLine("----------------AS---------"); foreach (String data in dataStringList) { System.Console.WriteLine(data); } System.Console.WriteLine("----------------POGODA---------"); foreach (String data in dataStringList2) { System.Console.WriteLine(data); } //ImportDataClass importDataClass = new ImportDataClass(); //importDataClass.ImportDataFromExcel(excelFilepath); /* * string[] lines = { "First line", "Second line", "Third line" }; */ using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:/Users/dell/Desktop/les/textDataForPython.txt")) { file.WriteLine("data1"); foreach (string line in dataStringList) { if (!line.Contains("foobar")) { file.WriteLine(line); } } file.WriteLine("data2"); foreach (string line in dataStringList2) { if (!line.Contains("foobar")) { file.WriteLine(line); } } } Console.WriteLine("zapisano plik"); Console.WriteLine("otwieram pythona"); run_cmd(); void run_cmd() { ProcessStartInfo start = new ProcessStartInfo(); start.FileName = "Python C:/Users/dell/Desktop/les/siec.py"; start.Arguments = string.Format("{0} {1}"); start.UseShellExecute = false; start.RedirectStandardOutput = true; using (Process process = Process.Start(start)) { using (StreamReader reader = process.StandardOutput) { string result = reader.ReadToEnd(); Console.Write(result); } } } //string strCmdText = "Python C:/Users/dell/Desktop/les/siec.py"; //System.Diagnostics.Process.Start("CMD.exe", strCmdText); GetPythonResults getPythonResults = new GetPythonResults(); // Console.WriteLine(File.Exists(pythonResultsPath) ? "File exists." : "File does not exist."); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }