Click here to Skip to main content
15,887,746 members
Home / Discussions / C#
   

C#

 
General[Message Deleted] Pin
MorganSim6-Sep-08 13:21
MorganSim6-Sep-08 13:21 
GeneralRe: Am I welcome! Pin
Blue_Boy6-Sep-08 13:41
Blue_Boy6-Sep-08 13:41 
GeneralRe: Am I welcome! Pin
MorganSim6-Sep-08 22:41
MorganSim6-Sep-08 22:41 
GeneralRe: Am I welcome! Pin
Blue_Boy6-Sep-08 22:46
Blue_Boy6-Sep-08 22:46 
QuestionRe: Multiple forms Pin
MorganSim6-Sep-08 23:25
MorganSim6-Sep-08 23:25 
QuestionRPC and permissions on new process Pin
erikkl20006-Sep-08 6:20
erikkl20006-Sep-08 6:20 
AnswerRe: RPC and permissions on new process Pin
Manas Bhardwaj9-Sep-08 5:33
professionalManas Bhardwaj9-Sep-08 5:33 
GeneralRe: RPC and permissions on new process [modified] Pin
erikkl20009-Sep-08 5:43
erikkl20009-Sep-08 5:43 
I was able to finally get this to nightmare to work.

This is so weird because I would have thought that all I needed to do would be do a .ReadToEnd(); but this just made
the app hang up.

So I have had to do this see saw type of push pull the stream until I get the data that I am looking for.


public bool CheckIfDomainZoneNodeHasRecords(string server, string zone, string node)
{
//
Process myProcess = null;
ProcessStartInfo myProcessStartInfo = null;
StreamReader myStreamReader = null;
string cmdFailed = string.Empty;
string dnsCmd = string.Empty;
StringBuilder output = null;
try
{
cmdFailed = "DNS Server failed";
//string cmdCompleted = "command completed successfully";
//Command failed: DNS_ERROR_NAME_DOES_NOT_EXIST 9714
//cmd server cmd zone node
//dnscmd afcc-inc-ns1 /enumrecords AFCCINC.COM handlers
dnsCmd = string.Format("dnscmd {0} /enumrecords {1} {2}", server, zone, node);
output = new StringBuilder();
myProcess = new Process();
myProcessStartInfo =
new ProcessStartInfo("cmd.exe");
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.CreateNoWindow = true;
myProcessStartInfo.RedirectStandardOutput = true;
myProcessStartInfo.RedirectStandardInput = true;
myProcessStartInfo.Arguments = dnsCmd;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();

myStreamReader = myProcess.StandardOutput;
do
{
output.Append(myStreamReader.ReadLine() + "\n");
} while (myStreamReader.Peek() >= 0);

myProcess.StandardInput.WriteLine(dnsCmd);
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
myProcess.StandardInput.WriteLine("\n");
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
myProcess.StandardInput.WriteLine("\n");
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
myProcess.StandardInput.WriteLine("\n");
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);
do
{
output.Append(myStreamReader.ReadLine());
} while (myStreamReader.Peek() >= 0);

myStreamReader.Close();
myProcess.Close();

Console.WriteLine(output.ToString());

if (output.ToString().ToLower().Contains(cmdFailed.ToLower()))
return false;//0
return true;
}
catch (Exception ex)
{
System.Net.Mail.MailMessage mm = null;
SmtpClient smtp = null;
mm =
new System.Net.Mail.MailMessage
(new System.Net.Mail.MailAddress("problems@afccDnsManager.com"),
new System.Net.Mail.MailAddress("support@afccinc.com"));
//
mm.Subject = "Problems with the AFCC Dns Manager Service";
mm.Body = "Message: " + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine;
mm.Body += "Source : " + Environment.NewLine + ex.Source;
smtp = new SmtpClient("smtp.afccinc.com");

smtp.Send(mm);

mm = null;
smtp = null;
//
return true;
}
finally
{
myProcess = null;
myProcessStartInfo = null;
myStreamReader = null;
cmdFailed = string.Empty;
dnsCmd = string.Empty;
output = null;
}
}

Any suggestion?

http://storefrontdoors.net

Erik

modified on Thursday, April 9, 2009 5:19 PM

QuestionFilling a textbox in form 1 by clicking a button in form 2 Pin
punkymt16-Sep-08 1:55
punkymt16-Sep-08 1:55 
AnswerRe: Filling a textbox in form 1 by clicking a button in form 2 Pin
#realJSOP6-Sep-08 2:03
mve#realJSOP6-Sep-08 2:03 
GeneralRe: Filling a textbox in form 1 by clicking a button in form 2 Pin
punkymt16-Sep-08 3:40
punkymt16-Sep-08 3:40 
QuestionHow Pin
Silvyster6-Sep-08 1:36
Silvyster6-Sep-08 1:36 
AnswerRe: How Pin
#realJSOP6-Sep-08 1:57
mve#realJSOP6-Sep-08 1:57 
AnswerRe: How Pin
Ed.Poore6-Sep-08 8:09
Ed.Poore6-Sep-08 8:09 
AnswerRe: How Pin
Mbah Dhaim6-Sep-08 8:16
Mbah Dhaim6-Sep-08 8:16 
GeneralRe: How Pin
#realJSOP6-Sep-08 9:10
mve#realJSOP6-Sep-08 9:10 
GeneralRe: How Pin
Mbah Dhaim6-Sep-08 9:28
Mbah Dhaim6-Sep-08 9:28 
GeneralRe: How Pin
#realJSOP6-Sep-08 10:36
mve#realJSOP6-Sep-08 10:36 
RantRe: How Pin
Mbah Dhaim6-Sep-08 11:25
Mbah Dhaim6-Sep-08 11:25 
GeneralRe: How Pin
Guffa6-Sep-08 12:43
Guffa6-Sep-08 12:43 
GeneralRe: How Pin
Blue_Boy6-Sep-08 13:07
Blue_Boy6-Sep-08 13:07 
GeneralRe: How Pin
#realJSOP7-Sep-08 2:01
mve#realJSOP7-Sep-08 2:01 
QuestionHow to convert one byte to string? Pin
nhatvhm6-Sep-08 0:44
nhatvhm6-Sep-08 0:44 
AnswerRe: How to convert one byte to string? Pin
prasadbuddhika6-Sep-08 0:59
prasadbuddhika6-Sep-08 0:59 
AnswerRe: How to convert one byte to string? Pin
User 66586-Sep-08 1:08
User 66586-Sep-08 1:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.