我正在使用带有ASP.NET核心Web API的Angular 2来实现文件上传来处理请求.
我的HTML代码如下:
<input #fileInput type="file"/>
<button (click)="addFile()">Add</button>
Run Code Online (Sandbox Code Playgroud)
和angular2代码
addFile(): void {
let fi = this.fileInput.nativeElement;
if (fi.files && fi.files[0]) {
let fileToUpload = fi.files[0];
this.documentService
.uploadFile(fileToUpload)
.subscribe(res => {
console.log(res);
});
}
}
Run Code Online (Sandbox Code Playgroud)
和服务看起来像
public uploadFile(file: any): Observable<any> {
let input = new FormData();
input.append("file", file, file.name);
let headers = new Headers();
headers.append('Content-Type', 'multipart/form-data');
let options = new RequestOptions({ headers: headers });
return this.http.post(`/api/document/Upload`, input, options);
}
Run Code Online (Sandbox Code Playgroud)
和控制器代码
[HttpPost]
public async Task Upload(IFormFile file)
{
if (file == …Run Code Online (Sandbox Code Playgroud) 我有一个创建零件的按钮。我需要获取当前在部件堆栈中可见的活动部件,并将其存储为某个值的键。我应该如何获得活动部分?我使用了以下代码,但它正在获取 partstack 中的所有部件。
MPart graphpart = partService
.createPart("com.abc.xyz.project.partDescriptor.1");
MPartStack stack = (MPartStack) modelService.find(
"com.abc.xyz.project.partstack.2", application);
for (int i = 0; i < stack.getChildren().size(); i++) {
if (stack.getChildren().get(i).isVisible()) {
System.out.println("values"
+ ((MPart) stack.getChildren().get(i)).getLabel());
application.getTransientData().put(
((MPart) stack.getChildren().get(i)).getLabel(),
selectedFiles);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在研究JFace Tableviewer.我对ColumnLabelProvider和的用法有点困惑ITableLabelProvider.我试图为tableviewer中的某一行着色(其中有1列字符串和其他3列中的复选框图像).我已经实现ITableLabelProvider并着色了该行,但在此之后禁用了编辑支持.所以我很困惑我是否应该使用ColumnLabelProvider或ITableLabelProvider?
有人可以给我一些想法吗?提前致谢
我正在计算两个时间戳之间的差异,其格式如下
2013-07-22 05:24:24.77
我使用以下方法来计算两个时间戳之间的差异
DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Date resDate = sdf.parse(responseData.getTimestamp().toString());
Date reqDate = sdf.parse(requestData.getTimestamp().toString());
System.out.println("response-->"+responseData.getTimestamp());
System.out.println("request-->"+requestData.getTimestamp());
System.out.println("diff-->"+(resDate.getTime()-reqDate.getTime()));
Run Code Online (Sandbox Code Playgroud)
在下列情况下,两个时间戳之间的差异为负.例如
回复日期:2013-07-22 05:24:24.77
申请日期:2013-07-22 05:24:24.663
结果是:
DIFF - > - 586
它应该减去像这样的"770-663",而不是将时间戳减去 "77-663".
任何人都可以建议我应该做出哪些改变,或者有没有其他方法可以做到这一点?
提前致谢
java ×3
eclipse ×2
angular ×1
asp.net ×1
e4 ×1
eclipse-rcp ×1
jface ×1
tableviewer ×1
timestamp ×1