Error
Server Error in '/unit/odbc' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1501: No overload for method 'PingAddress' takes 1 arguments
Source Error:
Line 89: lock (pingResults.Rows.SyncRoot)
Line 90: {
Line 91: pingResults.Rows.Add(ipAddress[i], GetMacAddress(ipAddress[i]), GetMacAddress(ipAddress[i]), PingAddress(ipAddress[i]), message, Location[i]);
Line 92: }
Line 93: // Thread.Sleep(10);
Source File: f:\Intranet\mejaitapps\unit\WebSiteWithDSN\Default2.aspx.cs Line: 91
Show Detailed Compiler Output:
Show Complete Compilation Source:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3062.0
public partial class _Default2 : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(@"Data Source=10.1.246.4;Initial Catalog=OCMS;User ID=dba_ntpc_meja_intranet;Password=alpha$890;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False");
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
refreshdata();
refreshdata1();
display1();
display2();
display3();
if (Session["load"] != null)
Session["load"] = Convert.ToString(Convert.ToInt32(Session["load"]) + 1);
else
Session["load"] = 1;
lblTime.Text = DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt");
}
int total = Convert.ToInt32(Label1.Text) + Convert.ToInt32(Label2.Text);
Label3.Text = total.ToString();
if (!IsPostBack)
{
BindTable();
BindTable1();
}
DataTable pingResults = new DataTable();
pingResults.Columns.AddRange(new DataColumn[] {
// new DataColumn("Date", typeof(DateTime)),
new DataColumn("IP", typeof(string)),
new DataColumn("MacAddress",typeof(string)),
new DataColumn("MachineName",typeof(string)),
new DataColumn("Speed",typeof(string)),
new DataColumn("Message",typeof(string)),
new DataColumn("Location",typeof(string))});
try
{
pingResults.Clear();
List<string> ipAddress = new List<string>();
ipAddress.Add("10.1.246.41");
ipAddress.Add("10.1.246.59");
ipAddress.Add("10.1.150.11");
ipAddress.Add("10.1.246.62");
ipAddress.Add("www.youtube.com");
ipAddress.Add("www.google.com");
List<string> Location = new List<string>();
Location.Add("UCB");
Location.Add("MGR");
Location.Add("Switchyard");
Location.Add("Township");
Location.Add("youtube");
Location.Add("google");
Location.Add("CCR ");
for (int i = 0; i < ipAddress.Count; i++)
{
Ping ping = new Ping();
PingReply pingReply = ping.Send(ipAddress[i].ToString());
string message = (pingReply.Status == IPStatus.Success) ? "OK" : "Down";
lock (pingResults.Rows.SyncRoot)
{
pingResults.Rows.Add(ipAddress[i], GetMacAddress(ipAddress[i]), GetMacAddress(ipAddress[i]), PingAddress(ipAddress[i]), message, Location[i]);
}
// Thread.Sleep(10);
}
GridView3.DataSource = pingResults;
GridView3.DataBind();
}
catch (Exception ex)
{
}
}
protected void OnTime(object sender, EventArgs e)
{
lblTime.Text = DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt");
}
public string GetMacAddress(string ipAddress)
{
string macAddress = string.Empty;
System.Diagnostics.Process pProcess = new System.Diagnostics.Process();
pProcess.StartInfo.FileName = "arp";
pProcess.StartInfo.Arguments = "-a " + ipAddress;
pProcess.StartInfo.UseShellExecute = false;
pProcess.StartInfo.RedirectStandardOutput = true;
pProcess.StartInfo.CreateNoWindow = true;
pProcess.Start();
string strOutput = pProcess.StandardOutput.ReadToEnd();
string[] substrings = strOutput.Split('-');
if (substrings.Length >= 8)
{
macAddress = substrings[3].Substring(Math.Max(0, substrings[3].Length - 2))
+ "-" + substrings[4] + "-" + substrings[5] + "-" + substrings[6]
+ "-" + substrings[7] + "-"
+ substrings[8].Substring(0, 2);
return macAddress;
}
else
{
return "not found";
}
}
private static long PingAddress(string address, int timeout)
{
try
{
Ping pingClass = new Ping();
PingReply pingReply = pingClass.Send(address, timeout);
return pingReply.RoundtripTime;
}
catch (Exception e)
{
}
return -1;
}
private string GetMachineName(string ipAdress)
{
string machineName = string.Empty;
try
{
IPHostEntry hostEntry = Dns.GetHostEntry(ipAdress);
machineName = hostEntry.HostName;
}
catch (Exception ex)
{
}
return machineName;
}
}