//work in progress, dokończyć public DataTable SideContentToDataTable(SideContent content) { DataTable dataTable = new DataTable(); dataTable.Columns.Add("Description"); dataTable.Columns.Add("Operation"); dataTable.Columns.Add("Text"); dataTable.Columns.Add("XPath"); DataRow row = dataTable.NewRow(); row[0] = "plugin init: load website"; row[1] = "goToUrl"; row[2] = content.url; row[3] = ""; dataTable.Rows.Add(row); row = dataTable.NewRow(); row[0] = "plugin init: reload website"; row[1] = "refresh"; row[2] = ""; row[3] = ""; dataTable.Rows.Add(row); foreach (SideContent.Test t in content.tests) { foreach (SideContent.Test.Command c in t.commands) { row = dataTable.NewRow(); Guid guid = Guid.NewGuid(); row[0] = "plugin: " + c.command + " " + guid.ToString().Substring(0, 2).ToUpper(); //todo row[1] = c.command; row[2] = c.value ?? ""; if (c.targets.Count() > 0) { row[3] = (c.targets.Where(tr => tr[0].Contains("id=") && tr[1] == "id").FirstOrDefault() //później zostanie poprawione w translate //?? fajnie by było zacząć korzystać z id, bo bardziej czytelne w scenariuszu, ale to dłuższy temat ?? c.targets.Where(tr => tr[0].Contains("xpath") && tr[1].Contains("idRelative")).FirstOrDefault() ?? c.targets.Where(tr => tr[0].Contains("xpath") && tr[1].Contains("attributes")).FirstOrDefault() ?? c.targets.Where(tr => tr[0].Contains("xpath") && tr[1].Contains("position")).FirstOrDefault() ?? c.targets.Where(tr => tr[0].Contains("xpath")).FirstOrDefault() ?? new string[] { "no xpath found (inner)" })[0] ?? "no xpath found (outer)"; //dla google / aol chrzani się atributes //dla tarisa nie ma relative //1. relative //2. attributes //3. position //4. dowolne } dataTable.Rows.Add(row); } } dataTable = TranslateSideContentDT(dataTable); return(dataTable); }
public void ReadSideSaveSql(string sideFileName, string csvFileName) { SideContent content = GetSideContent(ReadSideFile(sideFileName)); SaveDataTableToSqlFile(csvFileName, SideContentToDataTable(content)); }