我真的遇到了这个问题.我在Windows机器上(具有管理员权限),我想开始设置我的工作环境与vagrant.
问题是我收到错误(下来),我找不到任何解决方案......我正在使用最新的虚拟盒和流浪汉版本.
错误代码:
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/util/is_port_open.rb:21:in `initialize': The requested address is not valid in its context. - connect(2) for "0.0.0.0" port 7755 (Errno::EADDRNOTAVAIL)
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/util/is_port_open.rb:21:in `new'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/util/is_port_open.rb:21:in `block in is_port_open?'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:88:in `block in timeout'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:32:in `block in catch'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:32:in `catch'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:32:in `catch'
from C:/HashiCorp/Vagrant/embedded/lib/ruby/2.2.0/timeout.rb:103:in `timeout'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/util/is_port_open.rb:19:in `is_port_open?'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:248:in `port_check'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:121:in `[]'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:121:in `block in handle'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:257:in `block in with_forwarded_ports'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:253:in `each'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:253:in `with_forwarded_ports'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:98:in `handle'
from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.9.3/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:42:in `block in …Run Code Online (Sandbox Code Playgroud) 我正在使用Entity Framework模型数据来处理来自数据库的数据(CRUD操作).我想从表中获取所有数据(不只是一个).
这是数据库模型:

我想从所有表中获取多个数据.
目前我正在使用显示的查询,但此查询的问题是我从Contact表中获取了多个值,而其他表只显示了一个结果.有人知道为什么我的查询不起作用以及如何从表中获取所有多个数据.
这是查询/函数从数据库获取所有数据:
ContactsEntities db = new ContactsEntities();
//get all contacts
public JsonResult GetAll()
{
var data = (from c in db.Contacts
from e in db.Emails.Where(x => x.id == c.id).DefaultIfEmpty()
from p in db.Phones.Where(x => x.id == c.id).DefaultIfEmpty()
from t in db.Tags.Where(x => x.id == c.id).DefaultIfEmpty()
select new
{
id = c.id,
phones = p.number,
emails = e.email1,
tags = t.tag1,
firstname = c.firstname,
lastname = c.lastname,
address = c.address,
city = c.city,
bookmarked = c.bookmarked,
notes …Run Code Online (Sandbox Code Playgroud) 我在我的工作区内的根目录中创建了新项目(nodeJS),一段时间后我想将项目的客户端和服务器端分开.为此,我在项目的根目录中创建了两个文件夹(服务器和客户端),并将所有文件和目录移动到适当的文件夹.
之后我无法启动服务器,因为它说Swagger无法找到swagger.yaml文件(我将其移动到服务器文件夹)
{ Error: ENOENT: no such file or directory, open 'C:\Users\User\Documents\movieCollection\api\swagger\swagger.yaml'
at Error (native)
at Object.fs.openSync (fs.js:634:18)
at Object.fs.readFileSync (fs.js:502:33)
at C:\Users\User\AppData\Roaming\npm\node_modules\swagger\lib\commands\project\project.js:283:44
at findProjectFile (C:\Users\User\AppData\Roaming\npm\node_modules\swagger\lib\commands\project\project.js:308:14)
at readProject (C:\Users\User\AppData\Roaming\npm\node_modules\swagger\lib\commands\project\project.js:268:3)
at Command.edit (C:\Users\User\AppData\Roaming\npm\node_modules\swagger\lib\commands\project\project.js:240:3)
at Command.<anonymous> (C:\Users\User\AppData\Roaming\npm\node_modules\swagger\lib\util\cli.js:167:27)
at Command.listener (C:\Users\User\AppData\Roaming\npm\node_modules\swagger\node_modules\commander\index.js:301:8)
at emitTwo (events.js:106:13)
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Users\\User\\Documents\\movieCollection\\api\\swagger\\swagger.yaml' }
Run Code Online (Sandbox Code Playgroud)
我试图编辑节点服务器的config文件夹中的default.yaml文件,但问题仍然存在.
有没有办法将swagger项目配置指向新的laction(目录 - >服务器文件夹)?
default.yaml:
# swagger configuration file
# values in the swagger hash are system configuration for swagger-node
swagger:
fittingsDirs: [ api/fittings …Run Code Online (Sandbox Code Playgroud) 我需要将父数组中的转换数组转换为与我的数据库模型数据匹配的对象.
我有这样的数组:
emails: Array[2]
0: "example@mail.com"
1: "otherexample@mail.com"
id: 1
firstname: "Jane"
lastname: "Doe
Run Code Online (Sandbox Code Playgroud)
我想要实现的是将电子邮件数组转换为对象数组,如下所示:
emails: Array[2]
0:
{
name: "example@mail.com"
}
1:
{
name: "otherexample@mail.com"
}
id: 1
firstname: "Jane"
lastname: "Doe
Run Code Online (Sandbox Code Playgroud)
我试图使用此代码将数组转换为对象但由于某种原因它失败(没有数据显示 - >变量rv为空):
var rv = {};
for (var i = 0; i < dbInfo.emails.length; ++i)
if (dbInfo.emails[i] !== undefined) rv[i] = dbInfo.emails[i];
Run Code Online (Sandbox Code Playgroud)
有人知道我的代码失败的原因,有人知道这类问题的解决方案吗?
谢谢你.
我将数据更新到数据库时遇到问题.当我想更新数据时,Entitiy Framework会向可以有多行的表(具有外键的表)添加新行.
数据库模型:

当我更新电话/联系人或标签实体时,实体框架会自动添加新行而不是更新它
这是我使用的代码:
public string UpdateContact(Contact contact)
{
if (contact != null)
{
int id = Convert.ToInt32(contact.id);
Contact Updatecontact = db.Contacts.Where(a => a.id == id).FirstOrDefault();
Updatecontact.firstname = contact.firstname;
Updatecontact.lastname = contact.lastname;
Updatecontact.address = contact.address;
Updatecontact.bookmarked = contact.bookmarked;
Updatecontact.city = contact.city;
Updatecontact.notes = contact.notes;
Updatecontact.Emails1 = contact.Emails1;
Updatecontact.Phones1 = contact.Phones1;
Updatecontact.Tags1 = contact.Tags1;
db.SaveChanges();
return "Contact Updated";
}
else
{
return "Invalid Record";
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:
这是EF模型代码:
联系:
public partial class Contact
{
public Contact()
{
this.Emails1 = new …Run Code Online (Sandbox Code Playgroud) 我正在使用具有类的按钮为每个表单动态加载Invisible reCAPTCHA g-recaptcha.
我遇到的问题是验证码没有正确加载,我不知道为什么.我关注验证码网站上的文档,我不知道如何以及为什么我收到此错误:
Uncaught Error: Missing required parameters: sitekey
Run Code Online (Sandbox Code Playgroud)
有谁知道问题出在哪里?
这是我使用的代码:
<script src='https://www.google.com/recaptcha/api.js?onload=onloadCallback&hl={{ app.request.locale|default(defaultLang) }}' async defer></script>
Run Code Online (Sandbox Code Playgroud)
JS
var onloadCallback = function () {
$("button.g-recaptcha").each(function () {
var el = $(this);
//SITE_KEY is actually hard coded string.
//It is string that google provided. I just remove it for security reasons...
grecaptcha.render($(el).attr("id"), {
"sitekey": SITE_KEY,
"size": "invisible",
"badge": "inline",
"callback": function (token) {
$(el).parent().find(".g-recaptcha-response").val(token);
$(el).closest("form").submit();
}
}, true);
});
$("button.g-recaptcha").click(function(event) {
event.preventDefault();
grecaptcha.execute();
});
};
Run Code Online (Sandbox Code Playgroud)
HTML示例:
<button
type="submit"
id="submitReviewButton" …Run Code Online (Sandbox Code Playgroud) 我想计算两天之间的日期差异.问题是,当我计算天数时,计算中缺少一天(当天).
可以说date1是20-12-2014,date2是21-12-2014.使用这两个日期的DateTime :: Diff的结果为0(我想成为1,而不是零)
我错过了什么不好或DateTime :: Diff计算日期差异像我上面解释的那样?
这是我正在使用的代码(我希望以天显示日期差异):
$currentDay = new DateTime();
$listDay = new DateTime($results["date"]);//from mysql database (output is like 21-12-2014
$interval = $currentDay->diff($listDay);
$daysLeft=(int)$interval->format("%r%a");
Run Code Online (Sandbox Code Playgroud) 我将angularJS应用程序从xampp移动到ASP.NET Visual Studio.当我加载我的应用程序时,我收到错误消息,无法找到模板文件.
我尝试了几种方法,但没有一种方法有效......有人知道问题在哪里吗?
文件层次结构截图:

这里是包含模板的JS代码:
app.config(function ($routeProvider) {
$routeProvider
.when('/contacts',
{
controller: 'ContactsController',
templateUrl: '"/home/contacts.html'
})
.when('/add-contact',
{
controller: 'ContactAddController',
templateUrl: '/home/addContact.html'
})
.when('/edit-contact/:contactId',
{
controller: 'ContactEditController',
templateUrl: '/home/editContact.html'
})
.when('/display-contact/:contactId',
{
controller: 'ContactDetailsController',
templateUrl: '/home/displayContact.html'
})
.otherwise({ redirectTo: '/contacts' });
});
Run Code Online (Sandbox Code Playgroud)
这是RouteConfig.cs(我在创建新项目时保留原样)
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
Run Code Online (Sandbox Code Playgroud) 我在将变量(数据)传递给所有视图时遇到问题。我创建了 BaseController 来扩展默认的 Laravel 控制器,并在那里定义“全局”变量。当我使用 BaseController 扩展其他控制器时,出现变量未定义的错误。有人知道问题出在哪里吗?
这是代码:
namespace App\Http\Controllers;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use Sentry;
use Illuminate\Http\Request;
use View;
class BaseController extends Controller {
public function __construct() {
$obavijesti="Other data";
$izbornici="Some data";
View::share ( 'izbornici', $izbornici );
View::share ( 'obavjesti', $obavjesti );
}
}
class AdminController extends BaseController {
.
.
.
echo '<pre>';var_dump($izbornici);echo '</pre>';//Error pop ups here
.
.
.
}
Run Code Online (Sandbox Code Playgroud) 我正在通过一个在线教程(构建Web应用程序)学习ASP.NET.问题是当我重复使用导师代码时,我坚持这个错误:
Error 1 The type or namespace name 'Uri' could not be found (are you missing a using directive or an assembly reference?)
Run Code Online (Sandbox Code Playgroud)
我试图包含几个名称空间(如System.Uri),但没有一个工作.有人知道问题出在哪里,我需要做些什么才能解决问题?
这是代码:
using System.Collections.Generic;
using System.Net;
using System.Linq;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Web;
using System.Web.Http;
using System.Net.Http;
using System.Data.Entity.Infrastructure;
using System.Uri;
public HttpResponseMessage Post(Friend friend)
{
if (ModelState.IsValid)
{
db.Friends.Add(friend);
db.SaveChanges();
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, friend);
response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = friend.FriendId }));
return response;
}
else
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); …Run Code Online (Sandbox Code Playgroud) asp.net ×4
c# ×3
javascript ×3
angularjs ×2
php ×2
arrays ×1
datetime ×1
laravel ×1
laravel-5 ×1
node.js ×1
recaptcha ×1
sql ×1
swagger ×1
swagger-2.0 ×1
swagger-ui ×1
vagrant ×1
vagrantfile ×1
virtualbox ×1