Adding excel data into hash table:
Hashtable ExcelSheets = new Hashtable();
System.Data.DataTable dt1 = new System.Data.DataTable();
da.Fill(dt1);
System.Data.DataRow dr;
//System.Data.DataColumn dc;
#endregion
# region adding excel file into hash table
if (dt1.Rows.Count > 0)
{
for (int c = 0; c < dt1.Rows.Count; c++)
{
// if (c > 1)
// {
dr = dt1.Rows[c];
try
{
if (dr[1].ToString().ToLower() == "Risk".ToLower() || dr[1].ToString().ToLower() == "Health".ToLower())
{
ExcelSheets.Add(dr[0].ToString().ToLower(), dr[1].ToString().ToLower().Remove(1));
continue;
}
continue;
}
catch (Exception)
{
}
}
adding xml into hash table:
Hashtable hstIpIssueXml = new Hashtable();
#region Adding contents of IpIssue.xml into HashTable
foreach (XmlNode nodeTools in nodeToolsList)
{
try
{
hstIpIssueXml.Add(nodeTools.Attributes["IssueName"].Value,
nodeTools.Attributes["Classification"].Value);
using (StreamWriter logWriter = File.AppendText("E:\\log.txt"))
{
// logWriter.WriteLine("PASS " + stdIpissues.IpIssue + " verified");
Console.WriteLine("writing....");
logWriter.WriteLine("issue name = " +
nodeTools.Attributes["IssueName"].Value);
logWriter.WriteLine("Classification = " +
nodeTools.Attributes["Classification"].Value);
}
}
catch (Exception ex)
{
// Log.WriteLogEntries
// (nodeTools.Attributes["Name"].Value,
// string.Empty,
// "Duplicate Entries in EngagementManifest.xml");
}
}
#endregion
comparing these two hash tables:
foreach (IpIssues.IpIssueRow issueRow in stdIpissues.IpIssue.Rows)
{
for (int c = 0; c < dt1.Rows.Count; c++)
{
dr = dt1.Rows[c];
try
{
if (dr[0].ToString().ToLower() == issueRow.IssueName.ToLower())
{
if (ExcelSheets.ContainsValue(issueRow.Classification))
{
using (StreamWriter logWriter = File.AppendText("e:\\log.txt"))
{
logWriter.WriteLine("PASS ..." + issueRow.IssueName + " verified");
}
// Log.WriteLogEntries("PASS " + stdIpissues.IpIssue + " verified");
}
else
{
/*
using (StreamWriter logWriter = File.AppendText("e:\\log.txt"))
{
logWriter.WriteLine("fail " + issueRow.IssueName + " can NOT be verified");
}
// Log.WriteLogEntries("FAIL " + stdIpissues.IpIssue + " can NOT be verified");
*/
}
}
}
catch (Exception)
{
}
}
using (StreamWriter logWriter = File.AppendText("e:\\log.txt"))
{
logWriter.WriteLine("fail " + issueRow.IssueName + " can NOT be verified");
}
}
I can write contents of both these hash tables into log file... but my comparison code is not working well.... none of the issues got verified... there r no errors/exceptions while i run the code... i think der is problem in the logic of last code.... please help