Hi,
Have you tried this:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Net;
using System.Threading.Tasks;
namespace Domain
{
class Program
{
public SqlConnection objConn { get; set; }
public void Main(string[] args)
{
Console.WriteLine("hello");
string connectionString = "Server=Mayank-Pc;Database=reportserver;User=sa;Password=mayank;Trusted_Connection=False;";
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
Console.WriteLine("done");
string strSQLQuery = string.Empty;
strSQLQuery = @"SELECT top 3 'mayank-pc' AS ServerName,C.Path AS ReportPath,'salesorderid=43659' Parameter,0 MaxTimeDataRetrievalSeconds,0 MinTimeDataRetrievalSeconds,99 TotalCount FROM Catalog C where path like '/Reports/Sales%'";
SqlCommand cmd = new SqlCommand(strSQLQuery, conn);
SqlDataAdapter adapt = new SqlDataAdapter(cmd);
System.Data.DataTable table = new System.Data.DataTable("allPrograms");
adapt.Fill(table);
int dtCount;
dtCount = table.Rows.Count;
Console.WriteLine(dtCount);
List<string> urls = new List<string>();
foreach (DataRow dr in table.Rows)
{
string strPath = "http://" + dr["ServerName"].ToString() + "/ReportServer/Pages/ReportViewer.aspx?" + dr["ReportPath"].ToString() + "&rs:Command=Render&" + dr["Parameter"].ToString();
urls.Add(strPath);
Console.Write(strPath + "\n");
}
DownloadAsynchronous(urls);
Console.Read();
}
private void DownloadAsynchronous(List<string> urls)
{
Parallel.ForEach<string>(urls, url =>
{
Download(url);
});
}
private void Download(object strPath)
{
WebRequest myRequest = WebRequest.Create(strPath.ToString());
myRequest.Credentials = new NetworkCredential("mayank", "India@1985");
myRequest.Method = "GET";
myRequest.PreAuthenticate = true;
try
{
WebResponse myResponse = myRequest.GetResponse();
Console.Write("Success" + "\n");
}
catch (WebException e)
{
Console.Write("Error:" + e.ToString() + "\n");
}
}
}
}
you have lot of unwanted references in your code,try not include references if it is not used.
I hope this helps.
Regards
Jegan