本文整理汇总了C#中System.Diagnostics.Process.Kill方法的典型用法代码示例。如果您正苦于以下问题:C# System.Diagnostics.Process.Kill方法的具体用法?C# System.Diagnostics.Process.Kill怎么用?C# System.Diagnostics.Process.Kill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.Process
的用法示例。
在下文中一共展示了System.Diagnostics.Process.Kill方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Exec
public static string Exec(String command)
{
Console.WriteLine("command : " + command);
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/c " + command;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.Start();
var stdout = new StringBuilder();
var stderr = new StringBuilder();
p.OutputDataReceived += (sender, e) => {
if (e.Data != null) {
stdout.AppendLine(e.Data);
}
};
p.ErrorDataReceived += (sendar, e) => {
if (e.Data != null) {
stderr.AppendLine(e.Data);
}
};
p.BeginOutputReadLine();
p.BeginErrorReadLine();
var output = new StringBuilder();
var isTimeOut = false;
if (!p.WaitForExit(3000)) {
isTimeOut = true;
p.Kill();
}
p.CancelOutputRead();
p.CancelErrorRead();
output.Append(stdout.ToString());
output.Append(stderr.ToString());
if (isTimeOut) {
output.Append("TIMEOUT.");
}
return output.ToString();
}
示例2: CreateRepl
public void CreateRepl(Process replProcess)
{
var tabItem = new ReplTab();
var replEntity = new Entity<ReplState> { CurrentState = new ReplState() };
WireUpTheTextBoxInputToTheReplProcess(tabItem.InteractiveText, replProcess, replEntity);
WireUpTheOutputOfTheReplProcessToTheTextBox(tabItem.InteractiveText, replProcess, replEntity);
WireUpTheReplEditorCommandsToTheEditor(tabItem.InteractiveText, replProcess, replEntity, tabItem);
tabItem.CloseButton.Click +=
(o, e) =>
{
replProcess.Kill();
ReplManager.Items.Remove(tabItem);
};
ReplManager.Items.Add(tabItem);
ReplManager.SelectedItem = tabItem;
ReplToolWindow.Show();
}
示例3: runShellCommand
internal static bool runShellCommand(string command) {
System.Diagnostics.Process p = new System.Diagnostics.Process {
StartInfo = new System.Diagnostics.ProcessStartInfo {
WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden,
FileName = "cmd.exe",
Arguments = (@"CMD /C " + command)
}
};
p.Start();
p.WaitForExit(5000);
if (p.HasExited == false) { //Check to see if the process is still running.
if (p.Responding) {//Test to see if the process is hung up.
p.CloseMainWindow();//Process was responding; close the main window.
return false;
} else {
p.Kill(); //Process was not responding; force the process to close.
return false;
}
}
return true;
}
示例4: PrintPDF
public static void PrintPDF(string path)
{
string printerPath = "";
PrintDialog pd = new PrintDialog();
var result = pd.ShowDialog();
if (result == DialogResult.OK)
{
printerPath = pd.PrinterSettings.PrinterName;
}
//string printer = GetDefaultPrinter();
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = path;
process.StartInfo.Verb = "printto";
process.StartInfo.Arguments = "\"" + printerPath + "\"";
process.Start();
// I have to use this in case of Adobe Reader to close the window
process.WaitForInputIdle();
process.Kill();
}
示例5: Main
static void Main(string[] args)
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.Kill();
//InternetExplorer ie = new InternetExplorer();
//object Empty = 0;
//ie.BeforeNavigate2 += new DWebBrowserEvents2_BeforeNavigate2EventHandler(ie_BeforeNavigate2);
//ie.Visible = true;
//ie.Navigate("http://www.google.com", ref Empty, ref Empty, ref Empty, ref Empty);
//for (int i = 0; i < 10; i++)
//{
// Thread.Sleep(500);
// SendKeys.Send("{Tab}");
//}
//Thread.Sleep(10000);
//ie.Quit();
//CallBack call = new CallBack(EnumeratorWindow);
//EnumWindows(call, 0);
}
示例6: Reopen
/// <summary>
/// Restart the file reading at the beginning.
/// </summary>
/// <exception cref="IOException">The command cannot be executed.</exception>
/// <exception cref="InvalidOperationException">The stream is not reopenable</exception>
protected virtual void Reopen()
{
if (!reopenable) throw new InvalidOperationException("The stream is not reopenable.");
Finish();
if (proc != null)
{
try
{
proc.Kill();
proc.WaitForExit();
}
catch
{
}
//proc.WaitForExit();
proc.Close();
proc = null;
}
exitCode = -10;
try
{
// **** threads must be restarted!!
if (commandName.IndexOf('\\') < 0 && commandName.IndexOf('/') < 0) // && !File.Exists(commandName))
{
// should this be done? ***
string foundName = FindInPath(commandName);
if (foundName == null) foundName = FindInPath(commandName + ".exe");
if (foundName == null) foundName = FindInPath(commandName + ".cmd");
if (foundName == null) foundName = FindInPath(commandName + ".bat");
if (foundName == null)
{
throw new InvalidOperationException("Stream cannot be created to wrap '" + commandName +
"' because it cannot be found.");
}
commandName = foundName;
}
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(commandName, commandArgs);
//psi.WorkingDirectory = workingDir;
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
psi.CreateNoWindow = true;
psi.RedirectStandardInput = !skipStdin; // is this always OK?
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
#if DOTNET2
psi.StandardOutputEncoding = Encoding.UTF8;
#endif
psi.UseShellExecute = false;
if (psiCustomizer != null)
{
psiCustomizer(psi);
}
proc = System.Diagnostics.Process.Start(psi);
StreamReader outReader = proc.StandardOutput;
if (outReader == null)
{
throw new IOException("Cannot obtain output reader for command");
}
outStream = outReader.BaseStream;
if (outStream == null)
{
throw new IOException("Cannot obtain output stream for command");
}
#if !NO_BUFFER
// this is a small buffer to make byte operations not be horribly expensive:
//outStream = new BufferedStream(outStream, 4096 << 1);
outStream = new BufferedStream(outStream, BUFFER_SIZE);
#endif
errorThread = IOUtil.ConsumeBackground(proc.StandardError);
// is this always OK?
if (skipStdin)
{
inStream = null;
}
else
{
StreamWriter inWriter = proc.StandardInput;
if (inWriter == null)
{
throw new IOException("Cannot obtain input writer for command");
}
inStream = inWriter.BaseStream;
if (inStream == null)
{
throw new IOException("Cannot obtain input stream for command");
}
#if !NO_BUFFER
// this is a small buffer to make byte operations not be horribly expensive:
//inStream = new BufferedStream(inStream, 4096 << 1);
inStream = new BufferedStream(inStream, BUFFER_SIZE);
//.........这里部分代码省略.........
示例7: RunFfmpegCmd
/// <summary>
/// Runs the ffmpeg command
/// </summary>
public void RunFfmpegCmd()
{
// can we run it?
if (worker != null) {
Debug.LogError ("Please command is still running. Wait it to complete or kill it first");
return;
}
if(File.Exists(FinalOutfile)) {
if (!EditorUtility.DisplayDialog ("Overwrite?", FinalOutfile + " exists. Overwrite?", "Yes", "No")) {
Debug.Log ("Output file '" + FinalOutfile + "' exists, didn't overwrite");
return;
}
}
string ffmpegArgs = BuildFfmpegArgs ();
Debug.Log ("Running: " + ffmpegPath + " " + ffmpegArgs);
// start ffmpeg process inside a background worker so that it won't block the UI
worker = new BackgroundWorker ();
worker.WorkerReportsProgress = true;
worker.WorkerSupportsCancellation = true;
worker.DoWork += delegate(object sender, DoWorkEventArgs e) {
// start the process.
// currently we're doing it the easy way and not capturing standard input and output
// for creating better UX.
var process = new System.Diagnostics.Process ();
process.StartInfo = new System.Diagnostics.ProcessStartInfo (ffmpegPath, ffmpegArgs);
process.StartInfo.CreateNoWindow = false;
process.StartInfo.UseShellExecute = true;
process.Start ();
do {
process.WaitForExit (200);
if (worker.CancellationPending) {
process.Kill ();
}
} while(!process.HasExited);
ffmpegExitCode = process.ExitCode;
};
worker.RunWorkerAsync ();
}
示例8: Execute
static string Execute(string cmd, string arguments)
{
string result = "";
using (System.Diagnostics.Process shell = new System.Diagnostics.Process())
{
shell.StartInfo.UseShellExecute = false;
shell.StartInfo.FileName = cmd;
shell.StartInfo.Arguments = arguments;
shell.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
shell.StartInfo.RedirectStandardOutput = true;
shell.Start();
if (shell.WaitForExit(3 * 60 * 1000))
{
result = shell.StandardOutput.ReadToEnd();
shell.Close();
}
else
{
shell.Kill();
Kill(System.IO.Path.GetFileName(cmd), System.IO.Path.GetDirectoryName(cmd));
Kill("DW20.exe", System.IO.Path.GetDirectoryName(cmd));
}
return result;
}
}
示例9: RunPyScript
public bool RunPyScript(string sArguments, int iTimeOutMinutes)
{
System.Diagnostics.ProcessStartInfo procStartInfo = null;
System.Diagnostics.Process proc = null;
RegistryKey rk = null;
string sCommand = string.Empty;
try
{
// Get sPythonDir from registry
string sPythonDir = @"C:\Python27\ArcGIS10.1\";
string subkey = @"SOFTWARE\Python\PythonCore\2.7\InstallPath";
string value64 = string.Empty;
string value32 = string.Empty;
RegistryKey localKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);
localKey = localKey.OpenSubKey(subkey);
if (localKey != null)
{
sPythonDir = localKey.GetValue("").ToString();
}
else
{
RegistryKey localKey32 = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32);
localKey32 = localKey32.OpenSubKey(subkey);
if (localKey32 != null)
{
sPythonDir = localKey32.GetValue("").ToString();
}
}
sCommand = Path.Combine(sPythonDir, "python.exe") + " " + sArguments;
// Create the ProcessStartInfo using "cmd" as the program to be run,
// and "/c " as the parameters.
// "/c" tells cmd that you want it to execute the command that follows,
// then exit.
procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + sCommand);
// The following commands are needed to redirect the standard output.
// This means that it will be redirected to the Process.StandardOutput StreamReader.
procStartInfo.RedirectStandardOutput = true;
procStartInfo.RedirectStandardError = true;
procStartInfo.UseShellExecute = false;
// Do not create the black window.
procStartInfo.CreateNoWindow = true;
// Now you create a process, assign its ProcessStartInfo, and start it.
proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
proc.WaitForExit(iTimeOutMinutes * 60 * 1000);
// Get the output into a string.
_errOutput = proc.StandardError.ReadToEnd();
_stdOutput = proc.StandardOutput.ReadToEnd().TrimEnd('\r', '\n');
int exitCode = proc.ExitCode;
Console.WriteLine("Exit Code: {0}", proc.ExitCode);
if (exitCode != 0 && (!(string.IsNullOrEmpty(_errOutput))))
{
_errOutput = "Error in RunPyScript! Command: " + sCommand + Environment.NewLine + _errOutput;
return false;
}
return true;
}
catch (Exception objException)
{
Console.WriteLine(objException.Message);
// Log the exception and errors.
_errOutput = "Error in RunPyScript! Command: " + sCommand + Environment.NewLine + objException.Message;
return false;
}
finally
{
if (!(proc == null))
{
if (!(proc.HasExited))
{
proc.Kill();
}
proc = null;
}
rk = null;
}
}
示例10: OnStart
//////////////////////////////////////////////////////////////////////////
/// <summary>
/// </summary>
//////////////////////////////////////////////////////////////////////////
private void OnStart(object sender, DoWorkEventArgs e)
{
var nantCommand = Properties.Settings.Default.NANT_COMMAND;
var nantArguments = string.Format(Properties.Settings.Default.NANT_PARAMS, m_Filename, m_TargetNode["name"]);
var workingDir = Path.GetDirectoryName( m_Filename );
if ( !Path.IsPathRooted( nantCommand ) && !string.IsNullOrEmpty(workingDir) )
{//if the path is not rooted, then make it relative to the mFileName path.
nantCommand = Path.Combine( workingDir, nantCommand );
}
try
{
string nantOutput = null;
// Create and initialize the process
m_NAntProcess = new System.Diagnostics.Process();
m_NAntProcess.StartInfo.UseShellExecute = false;
m_NAntProcess.StartInfo.RedirectStandardError = true;
m_NAntProcess.StartInfo.RedirectStandardOutput = true;
m_NAntProcess.StartInfo.CreateNoWindow = true;
m_NAntProcess.StartInfo.FileName = nantCommand;
m_NAntProcess.StartInfo.WorkingDirectory = workingDir;
m_NAntProcess.StartInfo.Arguments = nantArguments;
// Start process
m_NAntProcess.Start();
// Read standard output and write string in console
while ((nantOutput = m_NAntProcess.StandardOutput.ReadLine()) != null)
{
if (m_BackgroundWorker.CancellationPending)
{
if (!m_NAntProcess.HasExited)
{
m_NAntProcess.Kill();
m_NAntProcess.WaitForExit();
e.Cancel = true;
}
}
else
{
nantOutput += System.Environment.NewLine;
m_BackgroundWorker.ReportProgress(0, nantOutput);
}
}
}
catch (Exception e1)
{
// Trace exception on console
WriteConsole("[NAntAddin]: Unexpected error occured while executing command: "
+ Environment.NewLine
+ "\t" + nantCommand + nantArguments
+ Environment.NewLine
+ Environment.NewLine
+ "An exception has been raised with the following stacktrace:"
+ Environment.NewLine
+ " " + e1.Message
+ Environment.NewLine
+ e1.StackTrace
+ Environment.NewLine
+ Environment.NewLine
+ "Please check that NAnt command path is properly configured within NAntAddin options."
+ Environment.NewLine
);
}
}
示例11: Run_Import_ContextWithArchiveImage_Case1572
// Case1572: 1.1.06.11_Import Context_Normal_contains an archived image
public void Run_Import_ContextWithArchiveImage_Case1572()
{
int runCount = 0;
foreach (InputDataSet ids in this.Input.DataSets)
{
string patientdir = string.Empty;
runCount++;
Round r = this.NewRound(runCount.ToString(), "Acquisition");
CheckPoint pImportAnalysis = new CheckPoint("Import Context", "Import Context using conversiontool");
r.CheckPoints.Add(pImportAnalysis);
PatientService pa = new PatientService();
XMLParameter query = new XMLParameter("filter");
//XMLParameter psa = new XMLParameter("presentationstate");
//XMLParameterCollection psaCollection = new XMLParameterCollection();
for (int i = 0; i < ids.InputParameters.Count; i++)
{
if (ids.InputParameters.GetParameter(i).Step == "patient")
{
if (ids.InputParameters.GetParameter(i).Key == "patientdir")
patientdir = ids.InputParameters.GetParameter(i).Value;
else
query.AddParameter(ids.InputParameters.GetParameter(i).Key, ids.InputParameters.GetParameter(i).Value);
}
}
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = System.IO.Directory.GetCurrentDirectory() + "\\ConversionTool version 1.0.4.0\\conversiontool.exe";
p.StartInfo.Arguments = "-P\"" + patientdir + "\"";
p.Start();
System.Threading.Thread.Sleep(20000);
p.Kill();
XMLResult rslQuery = pa.queryPatients(query);
string puid = null;
if (rslQuery.IsErrorOccured)
{
pImportAnalysis.Result = TestResult.Fail;
pImportAnalysis.Outputs.AddParameter("archiveFMS Import", "Query Fail:", rslQuery.Message);
goto CLEANUP;
}
else
{
puid = rslQuery.SingleResult;
}
NewPatientService nps = new NewPatientService();
PatientListObjectsRequestType request = new PatientListObjectsRequestType();
request.type = PatientListObjectsType.all;
request.currentSpecified = true;
request.current = true;
request.patientInternalId = puid;
nps.listObjects(request);
System.Threading.Thread.Sleep(10000);
PatientListObjectsResponseType response = nps.listObjects(request);
if (!nps.LastReturnXMLValidateResult.isValid)
{
pImportAnalysis.Result = TestResult.Fail;
pImportAnalysis.Outputs.AddParameter("archiveContext Import", "List Fail:", "Response is not complied with XML Schema");
goto CLEANUP;
}
if (response.status.code != 0)
{
pImportAnalysis.Result = TestResult.Fail;
pImportAnalysis.Outputs.AddParameter("archiveContext Import", "List Fail:", response.status.message);
goto CLEANUP;
}
if (ids.ExpectedValues.GetParameter("currentps").Value != null)
{
if (response.presentationStates.Length.ToString() != ids.ExpectedValues.GetParameter("currentps").Value)
{
pImportAnalysis.Result = TestResult.Fail;
pImportAnalysis.Outputs.AddParameter("archiveContext Import", "Import Fail:", "Expected" + ids.ExpectedValues.GetParameter("currentps").Value + "PS, actual:" + response.presentationStates.Length.ToString());
goto CLEANUP;
}
}
request.current = false; // below to check non-current PS and analysis
response = nps.listObjects(request);
if (!nps.LastReturnXMLValidateResult.isValid)
{
pImportAnalysis.Result = TestResult.Fail;
pImportAnalysis.Outputs.AddParameter("archiveContext Import", "List Fail:", "Response is not complied with XML Schema");
goto CLEANUP;
}
if (response.status.code != 0)
{
pImportAnalysis.Result = TestResult.Fail;
pImportAnalysis.Outputs.AddParameter("archiveContext Import", "List Fail:", response.status.message);
goto CLEANUP;
}
//.........这里部分代码省略.........
示例12: InstallAppx
public InstallResult InstallAppx(string filepath)
{
var result = new InstallResult();
try
{
var sb = new StringBuilder();
sb.Append(@"add-appxpackage ");
sb.Append(filepath);
var process = new System.Diagnostics.Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.FileName = "powershell.exe";
process.StartInfo.Arguments = sb.ToString();
process.StartInfo.CreateNoWindow = false;
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
process.Start();
var stdout = process.StandardOutput;
var stderr = process.StandardError;
result.Output = stdout.ReadToEnd();
result.Error = stderr.ReadToEnd();
if (!process.HasExited)
process.Kill();
stdout.Close();
stderr.Close();
}
catch (Exception ex)
{
if (string.IsNullOrWhiteSpace(result.Error))
result.Error = ex.Message;
else
result.Error += Environment.NewLine + ex.Message;
}
finally
{
File.Delete(filepath);
}
return result;
}
示例13: MainForm_FormClosing
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
//Try to kill winvnc on exit in case it is still running.
//Since this is a single instance app there should only be one instance running
System.Diagnostics.Process p = new System.Diagnostics.Process();
if (Globals.WinVncProcessID != -1)
{
p = System.Diagnostics.Process.GetProcessById(Globals.WinVncProcessID);
p.Kill();
p.WaitForExit(); // give time to exit before proceeding to try the delete
}
//System.Diagnostics.Process.Start(System.IO.Path.Combine(Globals.ProcomSupportLocalAppDataDirectory, "winvnc.exe") & " -kill")
//System.Threading.Thread.Sleep(5000)
try
{
// Since this is a single instance app there should only be able to be one copy of this directory
// So we get rid of our temp files when finished.
//System.IO.Directory.Delete(Globals.MajorSilenceSupportLocalAppDataDirectory, true);
if (System.IO.Directory.Exists(Globals.MajorSilenceSupportLocalAppDataDirectory))
{
DeleteFilesRecursively(new DirectoryInfo(Globals.MajorSilenceSupportLocalAppDataDirectory));
}
}
catch (UnauthorizedAccessException uex)
{
MessageBox.Show("Error cleaning up temp support files." + uex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (IOException iex)
{
MessageBox.Show("Error cleaning up temp support files." + iex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
MessageBox.Show("MajorSilenceConnect Software Support is now closed.", "MajorSilenceConnect Support Closed", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
示例14: Main
//.........这里部分代码省略.........
if (lSide == "buttons" || lSide == "b")
buttonsString = rSide;
else if (lSide == "exec" || lSide == "e")
execString = rSide;
else if (lSide == "params" || lSide == "p")
paramsString = rSide;
else if (lSide == "time" || lSide == "t")
timeString = rSide;
else if (lSide == "contoller" || lSide == "c")
controllerString = rSide;
}
}
{
bool error = false;
int oVal = 0;
Console.ForegroundColor = ConsoleColor.Yellow;
foreach (var b in buttonsString.Split('+')) //Find Button Combo that is required
{
if (int.TryParse(b, out oVal))
buttonCombo += (int)Math.Pow(2, oVal);
else
{
if (buttonsString == string.Empty)
Console.WriteLine("A button combination is not specififed.");
else
Console.WriteLine("The button argument is not used properly.");
error = true;
break;
}
}
if (!System.IO.File.Exists(execString))
{
if (execString == string.Empty)
Console.WriteLine("An executable is not specififed.");
else
Console.WriteLine("The executable does not exist, it's possibly an invalid path.");
error = true;
}
if (!int.TryParse(timeString, out time))
{
Console.WriteLine("The time argument not used properly.");
error = true;
}
if (!int.TryParse(controllerString, out controllerNum))
{
Console.WriteLine("The controller argument not used properly.");
error = true;
}
if(error)
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Command Alt Purpose");
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("--buttons --b Button combination to close the program" + Environment.NewLine +
" --b=0+8+6" + Environment.NewLine +
"--exec --e Full path to the executable" + Environment.NewLine +
" --e=C:\\Emulators\\nestopia.exe" + Environment.NewLine +
"--controller --c ID of specific controller to use [Optional]" + Environment.NewLine +
" --c=0" + Environment.NewLine +
"--time --t Milliseconds to hold down the combination [Optional]" + Environment.NewLine +
" --t=2500" + Environment.NewLine +
"--params --p Parameters when launching the program [Optional]" + Environment.NewLine +
" --p=C:\\roms\\NES\\Super Mario Bros..nes");
Console.ForegroundColor = ConsoleColor.Gray;
return;
}
else
Console.ForegroundColor = ConsoleColor.Gray;
}
controller = new Controller(controllerNum, buttonCombo); //Controller class that handles button presses when checked
runProgram = new System.Diagnostics.Process(); //Start up the program
runProgram.StartInfo.FileName = execString;
runProgram.StartInfo.Arguments = paramsString;
runProgram.StartInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(execString);
runProgram.Start();
}
while(true)
{
if (!controller.comboPressed())
{
timer.Restart();
}
else if(timer.ElapsedMilliseconds >= time)
{
try
{
runProgram.Kill();
}
catch { }
return;
}
System.Threading.Thread.Sleep(35);
}
}
示例15: Run_Import_ArchivedFMS_Case1570
//Case 1570: 1.1.06.02_Import an archived FMS_Normal_contains shortcut of archived image(French FE Tool)
public void Run_Import_ArchivedFMS_Case1570()
{
int runCount = 0;
foreach (InputDataSet ids in this.Input.DataSets)
{
runCount++;
Round r = this.NewRound(runCount.ToString(), "Import FMS1");
CheckPoint pImportFMS = new CheckPoint("Import FMS1", "Import FMS using conversiontool");
r.CheckPoints.Add(pImportFMS);
string patientdir = ids.InputParameters.GetParameter("patientdir").Value;
string patient_id = ids.InputParameters.GetParameter("patient_id").Value;
string dpms_id = ids.InputParameters.GetParameter("dpms_id").Value;
//call conversiontool to import archivedFMS
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = System.IO.Directory.GetCurrentDirectory() + "\\ConversionTool version 1.0.4.0\\conversiontool.exe";
p.StartInfo.Arguments = "-P\"" + patientdir + "\"";
p.Start();
System.Threading.Thread.Sleep(20000);
p.Kill();
string puid = null;
PatientService ps = new PatientService();
XMLParameter cInputQuery = new XMLParameter("filter");
cInputQuery.AddParameter("dpms_id", dpms_id);
cInputQuery.AddParameter("patient_id", patient_id);
XMLResult rslQuery = ps.queryPatients(cInputQuery);
if (rslQuery.IsErrorOccured)
{
pImportFMS.Result = TestResult.Fail;
pImportFMS.Outputs.AddParameter("archiveFMS Import", "Query Fail:", rslQuery.Message);
SaveRound(r);
goto CLEANUP;
}
puid = rslQuery.SingleResult;
//trigger the post import of FMS
NewPatientService nps = new NewPatientService();
PatientListObjectsRequestType request = new PatientListObjectsRequestType();
request.type = PatientListObjectsType.all;
request.currentSpecified = true;
request.current = true;
request.patientInternalId = puid;
nps.listObjects(request);
//wait the post import completed
System.Threading.Thread.Sleep(10000);
PatientListObjectsResponseType response = nps.listObjects(request);
if (!nps.LastReturnXMLValidateResult.isValid)
{
pImportFMS.Result = TestResult.Fail;
pImportFMS.Outputs.AddParameter("archiveFMS Import", "List Fail:", "Response is not complied with XML Schema");
SaveRound(r);
goto CLEANUP;
}
if (response.status.code != 0)
{
pImportFMS.Result = TestResult.Fail;
pImportFMS.Outputs.AddParameter("archiveFMS Import", "List Fail:", response.status.message);
SaveRound(r);
goto CLEANUP;
}
if (response.fmss == null)
{
pImportFMS.Result = TestResult.Fail;
pImportFMS.Outputs.AddParameter("archiveFMS Import", "Import Fail:", "Expected 3 fms, actual none.");
SaveRound(r);
goto CLEANUP;
}
else if (response.fmss.Length != 3)
{
pImportFMS.Result = TestResult.Fail;
pImportFMS.Outputs.AddParameter("archiveFMS Import", "Import Fail:", "Expected 3 fms, actual:" + response.fmss.Length.ToString());
SaveRound(r);
goto CLEANUP;
}
if (response.presentationStates == null)
{
pImportFMS.Result = TestResult.Fail;
pImportFMS.Outputs.AddParameter("archiveFMS Import", "Import Fail:", "Expected 21 PS, actual none.");
SaveRound(r);
goto CLEANUP;
}
else if (response.presentationStates.Length != 21)
{
pImportFMS.Result = TestResult.Fail;
pImportFMS.Outputs.AddParameter("archiveFMS Import", "Import Fail:", "Expected 21 PS, actual:" + response.presentationStates.Length.ToString());
SaveRound(r);
goto CLEANUP;
}
foreach (PresentationStateType pstate in response.presentationStates)
{
//.........这里部分代码省略.........