void initSQLTable(ProcSql proc) { DataTable inTable = SQLFunction.GetResultTable(proc.InTable); DataRow[] sqlRows = new DataRow[ResTable.Rows.Count]; DataRowCollection resRows = ResTable.Rows; for (int i = 0; i < resRows.Count; i++) { DataRow newRow = inTable.Rows.Add(); foreach (KeyValuePair <string, string> field in proc.inFields) { switch (field.Key.ToLower()) { case "ip": newRow[field.Key] = Scan.GetLocalIPByte(); break; case "row_id": newRow[field.Key] = i; break; default: newRow[field.Key] = resRows[i][field.Value]; break; } } sqlRows[i] = newRow; } SQLFunction.ExecuteNonQuery( String.Format("delete from {0} where IP = 0x{1}", proc.InTable, Scan.GetLocalIPAddress(true)) ); SQLFunction.BulkWrite(proc.InTable, sqlRows); }
public string readList() { string report = string.Empty; string patch = @"c:\Users\IKotvytskyi\Documents\УкрСибБанк\"; string[] lines = System.IO.File.ReadAllLines($"{patch}xls-file.txt "); int i = 0; DataTable resultTable = SQLFunction.GetResultTable("__ukrSib"); foreach (string xlsPach in lines) { file.ReadFile($"{patch}{xlsPach}"); DataTable table = file.XlsTable; int rowCount = 0; string missingFields = ""; if (table != null) { rowCount = table.Rows.Count; string[] fields = fieldsAll; if (table.Columns[0].ColumnName == fieldsSap[0]) { fields = fieldsSap; } foreach (string colName in fields) { if (!table.Columns.Contains(colName) && colName != "") { missingFields += colName + "| "; } } if (missingFields == "") { writeToSql(resultTable, xlsPach, table, fields); } } report += $"\r\n{i++} {xlsPach} -- {rowCount} -- {missingFields}"; } return(report); }
public bool initSQLResult() { InSqlTable = SQLFunction.GetResultTable(SQLTableName); return(InSqlTable != null); }