我使用NetMQ来远程处理设备。它是基于服务器/客户端的架构。
我使用WPF和Xaml实现了一个GUI,它允许我将命令作为字符串发送并接收答案也作为字符串。
主机应用程序有一个 //set zip file name for download
$zipFilename = md5('file-' . time()) . '.zip';
//zip file name with path
$zipPath = Yii::$app->basePath . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $zipFilename;
//start adding the files into the zip archive
$zip = new \ZipArchive();
//open zip archive
$zip->open($zipPath, \ZipArchive::CREATE | ZipArchive::OVERWRITE);
for ($x = 1; $x <= $vlt; $x++) {
if (file_exists($tempPath . 'Client' . $x . '.pdf')) {
$zip->addFile(realpath($tempPath . DIRECTORY_SEPARATOR . 'Client' . $x . '.pdf'), 'Client' . $x . '.pdf');
}
}
//close the zip file
$zip->close();
//return zip archive name without path
Yii::$app->response->sendFile($zipPath);
。
int是一个ID,cmdStruct是一个定义命令结构的类,它是:Dictionary<int, cmdStruct> ListOfCommands()
,string cmdText
和string cmdHelpText
。
delegate cmdAction
当我发送命令&#34; list&#34;它应该显示在Dictionary中的所有命令,并且我用它键和值访问它以仅显示ID,cmdText和cmdHelpText。然后我使用append将它们放入public static Dictionary<int, CommandStructure> CollectionOfCommands = new Dictionary<int, CommandStructure>();
public class CommandStructure
{
public string mCommandName;
public string mCommandHelpText;
public Func<string> mFunc;
。
stringBuilder
除非我尝试将ListBox更改为ComboBox(DropDownList)以显示其上的所有可用命令,否则一切正常。但这个问题并没有奏效。我得到了垂直列出的命令,而不是横向列出的命令。
if (_clientCommand == "?" || _clientCommand == "list")
{
foreach (var cmd in CollectionOfCommands)
{
stringBuilder.Append(cmd.Key + Tab);
stringBuilder.Append(cmd.Value.mCommandName + Tab);
stringBuilder.Append(cmd.Value.mCommandHelpText + NewLine);
_serverResponse = stringBuilder.ToString();
}
}