Ejemplo n.º 1
0
        public static string getStringFromUrl(string Url)
        {
            string json = string.Empty;

            try
            {
                if (count < proxyList.Count())
                {
                    using (WebClient wc = new WebClient())
                    {
                        ProxyModel p        = proxyList[count];
                        WebProxy   webProxy = new WebProxy(p.IP, p.Port);

                        wc.Proxy = webProxy;
                        var str = wc.DownloadString(Url);

                        json = JObject.Parse(str).ToString();
                    }
                }
                else
                {
                    _updateProxyList();
                }
            }
            catch (Exception ex)

            {
                LoggerUtility.Write(ex.Message, Url);
                count++;
                if (count >= proxyList.Count)
                {
                    _updateProxyList();
                }

                LoggerUtility.Write("Changing IP to ", proxyList[count].IP);
                return(getStringFromUrl(Url));
            }
            return(json);
        }
Ejemplo n.º 2
0
        public static DataSet GetDataSetFromExcelFile(string file, string sheetName)
        {
            try
            {
                DataSet ds = new DataSet();

                string connectionString = GetConnectionString(file);

                using (OleDbConnection conn = new OleDbConnection(connectionString))
                {
                    conn.Open();
                    OleDbCommand cmd = new OleDbCommand();
                    cmd.Connection = conn;

                    // Get all rows from the Sheet
                    cmd.CommandText = "SELECT * FROM [" + sheetName + "$]";

                    DataTable dt = new DataTable();
                    dt.TableName = sheetName;

                    OleDbDataAdapter da = new OleDbDataAdapter(cmd);
                    da.Fill(dt);

                    ds.Tables.Add(dt);


                    cmd = null;
                    conn.Close();
                }

                return(ds);
            }
            catch (Exception ex)
            {
                LoggerUtility.Write("Error Reading File", ex.Message);

                throw;
            }
        }
Ejemplo n.º 3
0
 private static void _updateProxyList()
 {
     LoggerUtility.Write("Proxy List Ended", "Updating List");
     proxyList = pm.UpdateProxyList();
     count     = 0;
 }