我正在尝试使用C#中的参数执行命令行程序.我本以为,在C#中站起来实现这一目标是微不足道的,但即使本网站及其他网站上提供的所有资源,它也具有挑战性.我很茫然,所以我会提供尽可能详细的信息.
我当前的方法和代码在下面,在调试器中变量命令具有以下值.
command = "C:\\Folder1\\Interfaces\\Folder2\\Common\\JREbin\\keytool.exe -import -noprompt -trustcacerts -alias myserver.us.goodstuff.world -file C:\\SSL_CERT.cer -storepass changeit -keystore keystore.jks"
Run Code Online (Sandbox Code Playgroud)
问题可能是我如何调用和格式化我在该变量命令中使用的字符串.
关于可能出现什么问题的任何想法?
ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + command);
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
procStartInfo.CreateNoWindow = true;
Process process = new Process();
process.StartInfo = procStartInfo;
process.Start();
string result = process.StandardOutput.ReadToEnd();
Console.WriteLine(result);
Run Code Online (Sandbox Code Playgroud)
一旦完成,我就不会在变量结果中找回任何信息或错误.
我已经创建了 C# WPF 应用程序,我想为其创建测试应用程序。我在互联网上搜索过,我发现了以下测试框架:
努尼特
机器人框架
我很困惑为 C# WPF 应用程序选择最佳的测试框架。你能建议我吗
我用simplexml_load_filephp函数读过xml文件.
我将xml数据存储到php数组中,但在某些数组中显示xml的显示数组 like SimpleXMLElement Object ( [0] => some value )
当我打印xml数据时,它显示正常,但是当我将xml值分配给php数组时,它的显示如上面的数组中的xml对象
XML
<data>
<request>
<type>City</type>
<query>Anand, India</query>
</request>
<current_condition>
<observation_time>08:55 AM</observation_time>
<temp_C>28</temp_C>
<temp_F>82</temp_F>
<weatherCode>113</weatherCode>
<weatherDesc>Sunny</weatherDesc>
<windspeedMiles>9</windspeedMiles>
<windspeedKmph>14</windspeedKmph>
<winddirDegree>63</winddirDegree>
<winddir16Point>ENE</winddir16Point>
<precipMM>0.0</precipMM>
<humidity>23</humidity>
<visibility>10</visibility>
<pressure>1014</pressure>
<cloudcover>0</cloudcover>
</current_condition>
<weather>
<date>2012-12-22</date>
<tempMaxC>33</tempMaxC>
<tempMaxF>91</tempMaxF>
<tempMinC>18</tempMinC>
<tempMinF>64</tempMinF>
<windspeedMiles>11</windspeedMiles>
<windspeedKmph>17</windspeedKmph>
<winddirection>ENE</winddirection>
<winddir16Point>ENE</winddir16Point>
<winddirDegree>63</winddirDegree>
<weatherCode>113</weatherCode>
<weatherDesc>Sunny</weatherDesc>
<precipMM>0.0</precipMM>
</weather>
<weather>
<date>2012-12-23</date>
<tempMaxC>34</tempMaxC>
<tempMaxF>92</tempMaxF>
<tempMinC>18</tempMinC>
<tempMinF>65</tempMinF>
<windspeedMiles>9</windspeedMiles>
<windspeedKmph>15</windspeedKmph>
<winddirection>ENE</winddirection>
<winddir16Point>ENE</winddir16Point>
<winddirDegree>64</winddirDegree>
<weatherCode>113</weatherCode>
<weatherDesc>Sunny</weatherDesc>
<precipMM>0.0</precipMM>
</weather>
<weather>
<date>2012-12-24</date>
<tempMaxC>33</tempMaxC>
<tempMaxF>92</tempMaxF>
<tempMinC>18</tempMinC>
<tempMinF>64</tempMinF>
<windspeedMiles>9</windspeedMiles>
<windspeedKmph>14</windspeedKmph>
<winddirection>NE</winddirection>
<winddir16Point>NE</winddir16Point>
<winddirDegree>45</winddirDegree>
<weatherCode>113</weatherCode> …Run Code Online (Sandbox Code Playgroud) 我在特定日期显示了可用组件数量和库存历史成本的数据.使用下面的查询它的工作正常.
SELECT s.part_id,
sum(s.updated_quantity),
p.item_code,
sum(
(SELECT (s.updated_quantity * cost)
FROM inventory
WHERE inventory.id=s.inv_id)) AS tcost
FROM status_history AS s,
inventory AS i,
part_master AS p
WHERE s.action='add'
AND DATE(s.date_created)<='2013-04-09'
AND i.currency_id=1
AND s.inv_id=i.id
AND s.part_id=p.id
GROUP BY s.part_id
Run Code Online (Sandbox Code Playgroud)
我还想在单个字段中显示用逗号分隔的组件的位置名称.为了得到我想要的结果,我尝试了以下查询,但它只返回一个位置名称而不是逗号分隔的多个位置名称字符串.
SELECT s.part_id,
sum(s.updated_quantity),
p.item_code,
sum(
(SELECT (s.updated_quantity * cost)
FROM inventory
WHERE inventory.id=s.inv_id)) AS tcost,
CONCAT_WS(',',
(SELECT name
FROM location_master
WHERE id=i.location_id)) AS LOCATION
FROM status_history AS s,
inventory AS i,
part_master AS p
WHERE s.action='add'
AND DATE(s.date_created)<='2013-04-09'
AND i.currency_id=1 …Run Code Online (Sandbox Code Playgroud) 我在Linux 2.6.34上安装了php 5.4.13.
我使用套接字创建简单的客户端/服务器页面,但它不起作用.
它给予权限拒绝错误
下面是我的PHP代码
if (false == ($socket = socket_create(AF_INET, SOCK_STREAM, 0))) // create socket
{
$stringData= date("D M d, Y g:i A"). " socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "<br>";
echo $stringData;
}
else
{
$timeout = array('sec'=>5,'usec'=>500000);
socket_set_option($socket,SOL_SOCKET,SO_RCVTIMEO,$timeout);
if(false==($result = socket_connect($socket, $host, $port)))
{
$stringData= date("D M d, Y g:i A"). " socket_connect() failed: reason: " . socket_strerror(socket_last_error()) . "<br>";
echo $stringData;
socket_close($socket);
}
else
{
$stringData= date("D M d, Y g:i A"). " Socket …Run Code Online (Sandbox Code Playgroud) 我从此Regex链接获取Javascript正则表达式。但是它的匹配也是MAC地址的混合模式
/^([0-9a-f]{1,2}[\.:-]){5}([0-9a-f]{1,2})$/i
Run Code Online (Sandbox Code Playgroud)
例如
AA-BB.CC.DD.EE.FF
Run Code Online (Sandbox Code Playgroud)
根据上述正则表达式其真实,但我想在整个mac地址中匹配相同的量词。根据我的要求,上面的mac地址是错误的。
因此,请帮助我如何匹配相同的量词。即对于dot(。),找到5个而不是对dash(-)和冒号相同的混合模式
我试图导入 ResponseForm 但错误
编译失败。./src/components/projects/ProjectDetails.js 尝试导入错误:“ResponseForm”未从“./ResponseForm”导出。
发生。
ResponseForm 组件确实存在。路径似乎是正确的。我该如何解决?为什么会出现导入错误?
import {Component} from 'react'
import {connect} from 'react-redux'
import {createProject} from '../../store/actions/projectActions'
import { Redirect } from 'react-router-dom'
const ResponseForm = () => {
state = {
content: ''
}
handleChange = (e) => {
this.setState({
[e.target.id]: e.target.value
})
}
handleSubmit = (e) => {
e.preventDefault()
this.props.createProject(this.state)
}
return (
<div className="container">
<form onSubmit={handleSubmit} className="white">
<h5 className="grey-text text-darken-3">KAITO</h5>
<div className="input-field">
<button className="btn pink lighten-1 z-depth-0">TEST</button>
</div>
</form>
</div>
)
}
export default …Run Code Online (Sandbox Code Playgroud) 我有一个 youtube 视频,我需要在完成后触发一个事件。你知道如何?
我想从下面的货币使用php money_format函数.
(INR,USD,EUR,GBP,AUD,CNY,HKD,JPY)
Run Code Online (Sandbox Code Playgroud)
在我的系统中,我允许从上面的列表中选择货币,根据选择,我有显示金额.
我已经尝试过这个代码用于USD和INR
money_format('$%i',$amount); //USD
money_format('%!i',$amount); //INR
Run Code Online (Sandbox Code Playgroud)
我想要上面列出的所有货币的货币格式功能代码.
我现在已经学习了一点点PHP,而且大部分内容都非常简单.我唯一能做的就是让会议开始工作.谷歌在这方面的努力是无情的.
这可能是两个原因之一; 语法或我的软件.我目前正在使用EasyPHP 5.3.5.0在未连接到互联网的机器上构建本地网站.将其连接到互联网不是一种选择.
我目前对会话的了解是,许多与之相关的语法已被弃用,取而代之的是超全局$_SESSION数组,它更易于使用.start_session();必须在任何与会话相关的语法之前.但是,我的登录脚本没有建立会话,因为quick !isset ($_SESSION['username'])总是返回true.
我的脚本设置如下:
PHP包括login.php,这是一个表单.check_login.php验证了它,如果查询返回一行,它将重定向到login_success.php,它建立会话,给出欢迎消息,然后重定向(使用JavaScript)到主页.
有任何想法吗?
编辑以包含更多信息:
这是我的代码的概要:
include 'main_login.php';
if(!isset ($_SESSION['username'])){
...
Login form, action="cehcklogin.php" method="post"
...
}else{
var_dump ($_SESSION): // Just to see if it works
}
Connect to SQL
$username = $_POST['username'];
$password = $_POST['password'];
$username / $password stripslashes / mysql_real_escape_string
Query to find the username & password
$count = mysql_num_rows($result);
if($count = 1){
$_SESSION["username"] = $username;
$_SESSION["password"] = $password;
header("location:login_success.php");
}else{
echo "Wrong Username … 我想从表(mysql)中的一个记录的两个字段给出max.
我的表是:
CREATE TABLE `testtbl` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`startdate` date NOT NULL,
`enddate` date NOT NULL,
PRIMARY KEY (`userid`)
)
Run Code Online (Sandbox Code Playgroud)
例如我的数据是:
1,'2012-12-04','2013-02-02'
但是当我使用下面的sql时,我面临着错误.
sql代码是:
select max(startdate,enddate) from `testtbl`
Run Code Online (Sandbox Code Playgroud) 我有这个PHP代码,我收到此错误:解析错误:语法错误,意外'}',期待';' 在第120行的[文件位置]中
while($ array等)的行是第120行.
if($numrows != 0)
{
do
{
//echo "<a href='approve.php?ref=" . $array['id'] . "'>Your '" . $array['keywords'] . "' article has been written and needs to be reviewed.</a>";
//echo "<br />";
} while($array = mysql_fetch_array($result)) //While there are still rows in the SELECT query.
}
Run Code Online (Sandbox Code Playgroud)
想法?我必须失明.谢谢!
我在这样的mysql数据库的 select查询中使用 distinct
$query=mysql_real_escape_string($_GET['query']);
$query_for_result=mysql_query("SELECT DISTINCT *
FROM vendor
LEFT JOIN branches ON branches.vendor_id = vendor.vendor_id
WHERE
(vendor.name LIKE '%".$query."%'
OR vendor.description LIKE '%".$query."%'
OR branches.city LIKE '%".$query."%')");
$qrow=mysql_fetch_array($query_for_result);
if(empty($qrow)){
while($qrow=mysql_fetch_array($query_for_result)){
Some Code to display result
<?php
}
mysql_close();
}
?>
Run Code Online (Sandbox Code Playgroud)
问题是这个,它多次显示每个结果,它从分支表中显示每个结果和它喜欢的城市,(意味着:如果供应商表中的结果在分支表中有5个城市它将显示5次)