public void Execute() { sqlCommandTools = new SqlCommandTools(); htmlParser = new HtmlParser(); proxyCloction = new List <string>() { "118.99.113.14:3128", "51.255.132.59:3128", "51.75.75.193:3128", "176.9.192.215:3128", "46.4.115.48:3128", "84.16.227.128:3128", "207.180.253.113:3128", "209.97.191.169:3128", }; httpRequest = new HttpRequest(); //ProxyClient proxyClient = ProxyClient.Parse(ProxyType.Http, "212.237.57.103:8080"); //httpRequest.Proxy = proxyClient; Task.Run(() => WorkParseAndAddDBShope()); }
public ManagerShope() { sqlCommandTools = new SqlCommandTools(); }
public override void Execute() { Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); SqlConnection conn = new SqlConnection(Connstring); SqlCommand getNeedsCmd = new SqlCommand("YahooDataNeeds", conn); getNeedsCmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter selectAdapter = new SqlDataAdapter(getNeedsCmd); DataTable dataNeeds = new DataTable(); selectAdapter.Fill(dataNeeds); foreach (DataRow companyRequestRow in dataNeeds.Rows) { DateTime fromDate = (DateTime)companyRequestRow["NeedSince"]; DateTime now = DateTime.Now; string abbreviation = companyRequestRow["Abbreviation"] as string; int companyId = (int)companyRequestRow["CompanyId"]; string csv = CsvTools.GetCsvFromUrl(String.Format("http://ichart.finance.yahoo.com/table.csv?s={0}&a={1}&b={2}&c={3}&d={4}&e={5}&f={6}&g=d&ignore=.csv", abbreviation, (fromDate.Month - 1).ToString("X2"), fromDate.Day, fromDate.Year, (now.Month - 1).ToString("X2"), now.Day, now.Year)); DataTable dt = CsvTools.Csv2DataTable(csv); dt.Columns[0].ColumnName = "Date"; dt.Columns[1].ColumnName = "Open"; dt.Columns[2].ColumnName = "High"; dt.Columns[3].ColumnName = "Low"; dt.Columns[4].ColumnName = "Close"; dt.Columns[5].ColumnName = "Volume"; dt.Columns[6].ColumnName = "AdjClose"; SqlCommand insertCommand = new SqlCommand("InsertYahooHistoricalData", conn); insertCommand.CommandType = CommandType.StoredProcedure; SqlCommandBuilder.DeriveParameters(insertCommand); /* * insertCommand.Parameters.Add("@CompanyId", SqlDbType.Int); * insertCommand.Parameters.Add("@Date", SqlDbType.Date); * insertCommand.Parameters.Add("@Open", SqlDbType.Real); * insertCommand.Parameters.Add("@High", SqlDbType.Real); * insertCommand.Parameters.Add("@Low", SqlDbType.Real); * insertCommand.Parameters.Add("@Close", SqlDbType.Real); * insertCommand.Parameters.Add("@Volume", SqlDbType.BigInt); * insertCommand.Parameters.Add("@AdjClose", SqlDbType.Real); */ SqlCommandTools.MapParamsToColumnsExact(dt, insertCommand); DataTable typedDt = dt.Clone(); typedDt.Columns[0].DataType = typeof(DateTime); typedDt.Columns[1].DataType = typeof(float); typedDt.Columns[2].DataType = typeof(float); typedDt.Columns[3].DataType = typeof(float); typedDt.Columns[4].DataType = typeof(float); typedDt.Columns[5].DataType = typeof(long); typedDt.Columns[6].DataType = typeof(float); DataColumn companyColumn = new DataColumn("CompanyId", typeof(int)); typedDt.Columns.Add(companyColumn); foreach (DataRow row in dt.Rows) { typedDt.ImportRow(row); } foreach (DataRow typedRow in typedDt.Rows) { typedRow["CompanyId"] = companyId; } insertCommand.Connection = conn; SqlDataAdapter insertAdapter = new SqlDataAdapter(); insertAdapter.InsertCommand = insertCommand; try { conn.Open(); SqlTransaction transaction = conn.BeginTransaction(IsolationLevel.RepeatableRead); _lastOldId = SqlCommandTools.LastId(conn, "YahooHistoricalPrices"); insertAdapter.UpdateBatchSize = 1000; insertAdapter.InsertCommand.UpdatedRowSource = UpdateRowSource.None; insertAdapter.Update(typedDt); transaction.Commit(); _lastInsertedId = SqlCommandTools.LastId(conn, "YahooHistoricalPrices"); conn.Close(); } catch { conn.Close(); throw; } } }
public void Execute() { sqlCommandTools = new SqlCommandTools(); connectorEPN = new ConnectorEPN(); Task.Run(() => WorkShopNew()); }
public ManagerData() { sqlCommandTools = new SqlCommandTools(); connectorEPN = new ConnectorEPN(); }
public void Execute() { sqlCommandTools = new SqlCommandTools(); connectorEPN = new ConnectorEPN(); Task.Run(() => WorkUpdatePrice()); }