这是我的mvc3应用程序的路由配置
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
// Parameter defaults:
new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,这是mvc3应用程序的默认路由,您可以注意到我根本没有更改它.所以当我试图RouteUrl像这样使用url helper时
@Url.RouteUrl("Default",
new { Action = "RegistrarPago",
IDPago = ViewBag.IDPago,
confirmNumber = ViewBag.ConfirmationNumber },
Request.Url.Scheme)
Run Code Online (Sandbox Code Playgroud)
输出就是这个
http://localhost/DescuentoDemo/pago/RegistrarPago?IDPago=60&confirmNumber=1798330254
这个url基本上对于这个字符amp;是错误的帮助器有什么问题我假设这是一个编码问题,但为什么呢?
我有一个foreach循环,我需要验证该元素是否是我正在迭代的集合中的最后一个.我尝试过的:
foreach (var character in list) // list is of type `string`
{
if (character == list.Last())
{
}
}
Run Code Online (Sandbox Code Playgroud)
但在这种情况下,如果我"la la la"的if语句将执行在第二字符.
问题:如何编写if语句,以便在访问序列的最后一个元素时执行该语句?
我无法弄清楚我在这里做错了什么.这个非常短的计划:
#include <iostream>
#include <string>
#include <atomic>
#include <thread>
using namespace std;
int
main(int argc, char ** argv)
{
thread foo( []() {
cout << "Hello World" << endl;
return 0;
} );
foo.join();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编译时它完美地工作gcc (4.7.2):
$ g++ -ggdb -std=c++11 -pthread -o clang_thread_test clang_thread_test.cpp
$ ./clang_thread_test
Hello World
Run Code Online (Sandbox Code Playgroud)
但是,使用clang (3.2; x86_64-pc-linux-gnu; thread model: posix)它编译时无法执行:
$ clang++ -ggdb -std=c++11 -pthread -o clang_thread_test clang_thread_test.cpp
$ ./clang_thread_test
pure virtual method called
terminate called without an active …Run Code Online (Sandbox Code Playgroud) 我需要在php/mysql中比较日期和时间基本上我有一个应用程序和服务器应用程序需要连接到服务器以检查数据库中的新条目.服务器从应用程序接收日期时间作为字符串,这是在这里完成的
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy/mm/dd hh:mm:ss");
Calendar cal = Calendar.getInstance();
String time = dateformat.format(cal.getTime());
Run Code Online (Sandbox Code Playgroud)
服务器在这里接收数据
f (isset($_GET["time"]) || isset($_GET["user_id"])) {
$time = $_GET['time'];
$u_id = $_GET['user_id'];
$timestr=date('y-m-d H:i:s',strtotime($time));
$result = mysql_query("SELECT MAX(created_at)from room");
$Max_time = mysql_result($result, $row);
$dbMax_time = date('y-m-d H:i:s',strtotime($Max_time));
Run Code Online (Sandbox Code Playgroud)
并且需要在这里进行比较
if ($dbMax_time> $timestr) {
$NewRooms = mysql_query("SELECT * From room WHERE created_at> CAST($timestr AS TIME)");
}
Run Code Online (Sandbox Code Playgroud)
我如何去解决这个问题如何比较请帮助我修复它.
我有2个obj1和的列表obj2
var list1 = new List<obj1>();
var list2 = new List<obj2>();
Run Code Online (Sandbox Code Playgroud)
obj1和obj2共享一个名为name的字符串属性,我需要通过list2中可用的name属性值过滤list1,所以我做了以下操作
var filteredlist = list1.Where(o => list2.Select(o2 => o2.name)
.Distinct()
.Contains(o.name));
Run Code Online (Sandbox Code Playgroud)
以上Linq查询等于以下?
var distinctNames = list2.Select(o2 => o2.name).Distinct();
var filteredlist = list1.Where(o => distinctNames.Contains(o.name));
Run Code Online (Sandbox Code Playgroud)
我的问题是在第一个查询中clr制作一个临时变量来保存distinctNames,即使我没有像第二个查询那样自己创建它吗?或者它会在每次迭代时从list2重做Select Distinct吗?
如果它不创建临时变量,你会如何在一行中编写此查询?
我正在尝试使用Powershell脚本自动执行分支操作,如下所示:
$fromUrl = 'svn://some/from/url'
$toUrl = 'svn://some/to/url.'
[Array]$arguments = "copy", "-q", $fromUrl, $toUrl, "-m", "New branch"
echo "Branching from: " $fromUrl
echo "Branching to: " $toUrl
$copyResult = & svn $arguments
echo "Result: " $copyResult
echo "Switching to: " $toUrl
$switchResult = svn switch -q $toUrl ho-til-test
echo "Result: " $switchResult
Run Code Online (Sandbox Code Playgroud)
只要对SVN的调用有效,这应该可以正常工作; 然而,我想要的是捕获结果,并在调用失败时使用错误消息停止脚本.上面的脚本显然因为无效的URL而失败,但是结果没有被捕获,$copyResult并且$switchResult正如我所期望的那样.结果输出如下; 状态消息显示在我的两个结果变量的输出之前,它们是空的:
PS > .\PsExampleForSO.ps1
Branching from:
svn://some/from/url
Branching to:
svn://some/to/url.
svn: E731001: Unable to connect to a repository at URL 'svn://some/from/url'
svn: E731001: …Run Code Online (Sandbox Code Playgroud) 我在从对象列表中选择一个byte []时遇到一些麻烦,模型被设置为:
public class container{
public byte[] image{ get;set; }
//some other irrelevant properties
}
Run Code Online (Sandbox Code Playgroud)
在我的控制器中我有:
public List<List<container>> containers; //gets filled out in the code
Run Code Online (Sandbox Code Playgroud)
我试图拉下image一个级别,List<List<byte[]>>所以到目前为止,我有一个使用LINQ:
var imageList = containers.Select(x => x.SelectMany(y => y.image));
Run Code Online (Sandbox Code Playgroud)
但它扔了:
cannot convert from
'System.Collections.Generic.IEnumerable<System.Collections.Generic.IEnumerable<byte>>' to
'System.Collections.Generic.List<System.Collections.Generic.List<byte[]>>'
Run Code Online (Sandbox Code Playgroud)
显然它是选择字节数组作为一个字节?
一些指导将不胜感激!
所以我试着画一个X:
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
e.Graphics.DrawLine(new Pen(Color.Black, 1),
this.Width + 20 - 50,
20,
this.Width + 25 - 50,
10);
e.Graphics.DrawLine(new Pen(Color.Black, 1),
this.Width - 20 + 50,
20,
this.Width + 25 - 50,
10);
Run Code Online (Sandbox Code Playgroud)
但它看起来像一把斧头。无论我为第二行代码设置哪个值,它都是不正确的。
我正在 pl/SQL 中开发一些连接到多个外部服务的应用程序,
例子:
declare
utl_req utl_http.req;
utl_resp utl_http.resp;
begin
-- This line in production for security, but takes forever to get authorized
-- by oracle host provider :@
-- utl_http.set_wallet('file:/path/wallet', 'password');
-- In test env i would like something like
-- utl_http.set_option('CURLOPT_SSL_VERIFYHOST', false);
-- utl_http.set_option('CURLOPT_SSL_VERIFYPEER', false);
utl_req := utl_http.begin_request('https://login.microsoftonline.com/...
/oauth2/token', 'POST', 'HTTP/1.1');-- Die
--...more code
end;
Run Code Online (Sandbox Code Playgroud)
输出:
ORA-29024: Certificate validation failure
Run Code Online (Sandbox Code Playgroud)
有没有办法命令 Oracle 忽略证书验证以进行测试,无需等待将证书添加到钱包的身份验证。
类似于 php
$curl_request = curl_init();
curl_setopt($curl_request, CURLOPT_URL, 'https://login.microsoftonline.com/...
/oauth2/token');
curl_setopt($curl_request, CURLOPT_POST, 1);
// No thankyou …Run Code Online (Sandbox Code Playgroud) 我正在尝试在另一个Action中设置一个Action,但我传递给它的Action最终仍为null.这是一个愚蠢的例子:
Action<Action<VerifylocalResult>> docollectprint = (vl) =>
{
vl = (vlocres) =>
{
//DoStuff
};
//This returns false, indicating the action has been set:
Console.WriteLine((vl == null).ToString());
};
//Hookups
docollectprint(vlocobj.Action_NotExists);
//This returns true, so the action has not been set:
Console.WriteLine((vlocobj.Action_NotExists==null).ToString());
Run Code Online (Sandbox Code Playgroud)
我已经尝试过传递一个getter方法而不是真正的交易,但结果是一样的......最后它仍然是null.
Action<Func<Action<VerifylocalResult>>> docollectprint = (vl) =>
{
Action<VerifylocalResult> theaction = vl();
theaction = (vlocres) =>
{
//DoStuff
};
//This returns false, indicating the action has been set
Console.WriteLine((theaction == null).ToString());
};
//Hookups
docollectprint(() => { return vlocobj.Action_NotExists; });
//This returns …Run Code Online (Sandbox Code Playgroud)