我有SQL Server数据库,我才意识到我可以将其中一个列的类型更改int为bool.
如何在不丢失已输入该表的数据的情况下执行此操作?
我创建了一个WebApi和一个Cordova应用程序.我正在使用HTTP请求在Cordova应用程序和WebAPI之间进行通信.在WebAPI中,我实现了OAuth Bearer Token Generation.
public void ConfigureOAuth(IAppBuilder app)
{
var oAuthServerOptions = new OAuthAuthorizationServerOptions
{
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/token"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
Provider = new SimpleAuthorizationServerProvider(new UserService(new Repository<User>(new RabbitApiObjectContext()), new EncryptionService()))
};
// Token Generation
app.UseOAuthAuthorizationServer(oAuthServerOptions);
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
}
Run Code Online (Sandbox Code Playgroud)
这是在SimpleAuthorizationServerProvider实现中
public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
{
context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
// A little hack. context.UserName contains the email
var user = await _userService.GetUserByEmailAndPassword(context.UserName, context.Password);
if (user == null)
{
context.SetError("invalid_grant", "Wrong email or …Run Code Online (Sandbox Code Playgroud) 我有一个转发器,显示我的Projects表中的数据.有projectId,名称和描述.我在描述中使用了Substring(1,240).但有时字符串短于240,所以我得到了ArgumentOutOfRangeException.如果我得到例外,你能告诉我如何显示整个文本吗?这是我的代码.
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:Panel ID="pnlDisplayProjects" runat="server" Visible="true">
<center><h2><b>???????</b></h2></center>
<asp:Repeater ID="rptrProjects" runat="server">
<HeaderTemplate>
<table border="1" cellpadding="2" cellspacing="2" align="center" width="80%" style="background-color:#F7F6F3;">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td align="left" style="width:40px">
<asp:Label ID="LblProjectId" runat="server" Text='<%# Eval("ProjectID") %>' />
</td>
<td align="center">
<asp:Label ID="LblName" runat="server" Text='<%# Eval("Name") %>' />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="LblDescription" runat="server" Text='<%# Eval("Description").ToString().Substring(1, 240) + "..." %>'/>
<asp:HyperLink ID="HlMore" runat="server" NavigateUrl='<%#"~/Project/ViewProject.aspx?projectId=" + Eval("ProjectID") %>' Text="More" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</asp:Panel>
Run Code Online (Sandbox Code Playgroud)
protected override void OnPreRender(EventArgs e) …Run Code Online (Sandbox Code Playgroud) 我正在创建一个Web Api应用程序,我想使用承载令牌进行用户身份验证.我实现了令牌逻辑,按照这篇文章,一切似乎都运行正常.注意:我没有使用ASP.NET身份提供程序.相反,我为它创建了一个自定义用户实体和服务.
public class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureOAuth(app);
var config = new HttpConfiguration();
var container = DependancyConfig.Register();
var dependencyResolver = new AutofacWebApiDependencyResolver(container);
config.DependencyResolver = dependencyResolver;
app.UseAutofacMiddleware(container);
app.UseAutofacWebApi(config);
WebApiConfig.Register(config);
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
app.UseWebApi(config);
}
public void ConfigureOAuth(IAppBuilder app)
{
var oAuthServerOptions = new OAuthAuthorizationServerOptions
{
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/token"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
Provider = new SimpleAuthorizationServerProvider()
};
// Token Generation
app.UseOAuthAuthorizationServer(oAuthServerOptions);
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
}
}
Run Code Online (Sandbox Code Playgroud)
这是我对SimpleAuthorizationServerProvider类的实现
private IUserService _userService;
public IUserService UserService
{
get …Run Code Online (Sandbox Code Playgroud) dependency-injection autofac owin asp.net-web-api2 bearer-token
我正在使用MVC 4 Web Api,我希望在使用我的服务之前对用户进行身份验证.
我已经实现了一个授权消息处理程序,它可以正常工作.
public class AuthorizationHandler : DelegatingHandler
{
private readonly AuthenticationService _authenticationService = new AuthenticationService();
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
IEnumerable<string> apiKeyHeaderValues = null;
if (request.Headers.TryGetValues("X-ApiKey", out apiKeyHeaderValues))
{
var apiKeyHeaderValue = apiKeyHeaderValues.First();
// ... your authentication logic here ...
var user = _authenticationService.GetUserByKey(new Guid(apiKeyHeaderValue));
if (user != null)
{
var userId = user.Id;
var userIdClaim = new Claim(ClaimTypes.SerialNumber, userId.ToString());
var identity = new ClaimsIdentity(new[] { userIdClaim }, "ApiKey");
var principal = new ClaimsPrincipal(identity); …Run Code Online (Sandbox Code Playgroud) 我刚开始使用Mailchimp API.到目前为止,我已使用Node.js和配置了开放式身份验证Angular.js.我想从我的应用程序到Mailchimp列表实现客户(名字,姓氏和电子邮件)的导出.我想在一个Javaworker中这样做,所以我开始寻找一个Mailchimp API包装器Java.到目前为止,我已经设法找到ecwid-mailchimp包装器,但它适用于Mailchimp API v2.0,看起来该项目已经死了.
是否有JavaMailchimp API v3.0 的包装器的活动实现?
在新项目中使用旧API(v2.0)和死实现似乎不太好.
另一种方法是自己实施,但如果有人已经做了,那就浪费时间了.
我将ListView控件绑定到DataTable.DataTable有一个名为ProductID的列.有没有办法隐藏这个专栏,因为我以后需要它的价值?
我用Eclipse创建了一个Java应用程序,我正在使用Maven进行包管理.几天前,我能够配置我的应用程序以使用Dagger 1(将依赖项添加到pom文件,启用注释处理并将dagger,dagger-compile,javax和javawriter jar添加到Factory Path).经过与同事的几次讨论,我们决定使用Dagger 2.我尝试通过遵循Dagger 2文档将Dagger 1实现迁移到Dagger 2 ,但它没有用.
由于某些无法解释的原因,不会生成@Component带Dagger前缀的类.
因此我决定尝试Dagger 2 Coffee样品.
我创建了一个新的Eclipse Java项目,将其转换为Maven,将示例代码和Dagger 2依赖项添加到pom文件中:
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.0.1</version>
<optional>true</optional>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我的构建失败,出现以下错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
DaggerCoffeeApp_Coffee cannot be resolved
Run Code Online (Sandbox Code Playgroud)
我将Coffee组件接口解压缩到一个单独的文件(命名Coffee.java)并再次尝试,但我得到了同样的错误.
我从Dagger 1中移除了Factory Path罐子,但结果仍然相同.如果我尝试添加Dagger 2 jar,我会出现多个问题已发生窗口,其中包含以下错误文本
Errors occurred during the build.
Errors running builder 'Java Builder' on project 'dagger'.
com/google/common/collect/SetMultimap
我发现当我添加dagger-compilerjar 时会出现问题.
如果我从Factory Path中删除每个jar,则构建仍然失败. …
我用io.js和创建了一个API koa.js.
作为我正在使用的身体解析器中间件koa-body,它反过来使用co-body.
在我的一个API端点上,我正在接收POST请求,我需要访问请求的原始主体,因为我需要对其进行编码以验证请求是否有效.
有没有办法访问请求的原始主体?我试图用raw-body中间件,但如果我用它我打电话之前koa-body,将co-body用于koa-body休息.如果我在koa-body它不起作用后使用它.
app.use(function*(next){
let rawRequestBody = yield rawBody(this.req);
this.rawRequestBody = rawRequestBody;
yield next;
});
Run Code Online (Sandbox Code Playgroud)
编辑:
我认为我找到了解决方法,但我不知道这是否是最好的解决方案.我认为@greim的答案可能是解决这个问题的更好方法.
我在使用之前添加了以下代码koa-body:
app.use(function *(next) {
let url = this.req.url;
if(this.req.method == 'POST') {
let that = this;
this.req.rawBody = '';
this.req.on('data', function(chunk) {
that.req.rawBody += chunk;
});
}
yield next;
});
Run Code Online (Sandbox Code Playgroud) 我在我的Java应用程序中使用Apache Spark.我有两个DataFrame:df1和df2.该df1包含Rows的email,firstName和lastName.df2包含Rows email.
我想创建一个DataFrame:df3包含所有行df1,不包含哪个电子邮件df2.
有没有办法用Apache Spark做到这一点?我试图创建JavaRDD<String>的df1,并df2通过它们铸造toJavaRDD()和过滤df1包含所有电子邮件和在使用后subtract,但我不知道如何将新的映射JavaRDD到ds1并获得DataFrame.
基本上我需要所有df1不在其电子邮件中的行df2.
DataFrame customers = sqlContext.cassandraSql("SELECT email, first_name, last_name FROM customer ");
DataFrame customersWhoOrderedTheProduct = sqlContext.cassandraSql("SELECT email FROM customer_bought_product " +
"WHERE product_id = …Run Code Online (Sandbox Code Playgroud)