/// <summary> /// /// </summary> /// <param name="sourceConnexion"></param> /// <param name="destConnexion"></param> /// <param name="mode">Exclude, Include or Aucun</param> /// <param name="liste">Liste des tables lié à l'option Mode</param> public static void DataBaseIntegrate (string CsvFileName, string destConnexion, string destSchema, string destTable, string csvFileEncoding = "iso-8859-1") { Encoding enc = null; switch (csvFileEncoding) { case "UTF8": enc = Encoding.UTF8; break; case "ASCII": enc = Encoding.ASCII; break; case "BigEndianUnicode": enc = Encoding.BigEndianUnicode; break; case "Unicode": enc = Encoding.Unicode; break; case "UTF32": enc = Encoding.UTF32; break; case "UTF7": enc = Encoding.UTF7; break; case "iso-8859-1": enc = Encoding.GetEncoding(28591); break; default: enc = Encoding.Default; break; } ; DatabaseTable destDataTable = new DatabaseTable(destSchema, destTable); /* * MSDBIntegration sql = new MSDBIntegration(destinationConnection: destConnexion); * sql.BulkUpsertCsv(CsvFileName,destDataTable); */ SQLCopy.MSSQL2005_DBConnection DestinationConnection = new SQLCopy.MSSQL2005_DBConnection(destConnexion); using (var reader = new CsvReader(new StreamReader(CsvFileName, enc), true, ';')) { try { DestinationConnection.Open(); CsvDataAdapter adapter = new CsvDataAdapter(reader); int nbTobeMergedRows = adapter.Fill(DestinationConnection, destDataTable, "yyyyMMdd"); } catch (Exception e) { throw e; } finally { DestinationConnection.Close(); } } }
public static void ACTION_PROCESS_BulkCopy_DATA_FACTSET_DATA_1(string filepath) { DataSet ds = new DataSet("DATA_FACTSET"); MSSQL2005_DBConnection dest = new MSSQL2005_DBConnection(ENV); using (var reader = new CsvReader(new StreamReader(new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)), true, '|')) { reader.MissingFieldAction = MissingFieldAction.ReplaceByEmpty; CsvDataAdapter adapter = new CsvDataAdapter(reader); // TODO : ajouter un objet de mapping sur le csvDataApdapter int nbReadLines = adapter.Fill(dest, new DatabaseTable("dbo", "DATA_FACTSET")); } }
public override void ProcessData() { RaiseProcessingUpdate(new EventArg<string>("Retrieving FinViz data...")); foreach (var exchange in exhcanges) { CsvDataAdapter adapter = new CsvDataAdapter(true); adapter.DataRetrieveCompleted += adapter_DataRetrieveCompleted; adapter.DataRetrieveError += adapter_DataRetrieveError; string[] values = exchange.Split('='); if (values.Length == 2) { if (FilterString.Contains("&f=")) adapter.CurrentURL = exportUrl + FilterString + "," + values[1]; else adapter.CurrentURL = exportUrl + FilterString + "&f=" + values[1]; } else { adapter.CurrentURL = exportUrl; } adapter.RetrieveData(); } }
protected override void OnInnerProcessorCompleted(EventArg<System.Data.DataTable> e) { try { querySetCount = 0; RaiseProcessingUpdate(new EventArg<string>("Getting Yahoo Finance data...")); var col = e.Data.Columns.Add(FieldConstant.ExDividendDate, typeof(string)); col = e.Data.Columns.Add(FieldConstant.DividendPayDate, typeof(string)); col = e.Data.Columns.Add(FieldConstant.DividendYield, typeof(string)); col = e.Data.Columns.Add(FieldConstant.TargetPrice1y, typeof(float)); //get the filtered data //contruct the data //get back the table var result = ConstructURL(e.Data); foreach (string url in result) { CsvDataAdapter adapter = new CsvDataAdapter(false); adapter.DataRetrieveCompleted += adapter_DataRetrieveCompleted; adapter.DataRetrieveError += adapter_DataRetrieveError; adapter.CurrentURL = url; adapter.RetrieveData(); Interlocked.Increment(ref querySetCount); } } catch (Exception err) { RaiseProcessingError(new EventArg<Exception>(err)); } }