我可能没想到正确的方向.我对Dependency Injection和ASP.Net Core相当新.
我有一个ASP.Net核心网站,其中一个任务是将数据从Excel工作表导入用户将上传的数据库.excel表格可能很大,数据转换任务也很耗时,因此我希望在后台执行它们.即用户将上传工作表,响应将立即发送,后台作业/线程将导入数据.
我正在尝试通过以下方式运行后台作业:
Task.Run(() => ProcessImport(model));
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是Process导入方法调用具有存储库类的服务,这些存储库类通过作为Scoped添加的ASP.Net依赖注入容器访问AppDbContext,并且一旦响应被发回,就会释放上下文.我收到一个运行时异常,你不能在它被处置后使用上下文.
我的问题是,处理这种情况的最佳方法是什么?我应该制作AppDbContext单例吗?我应该在ProcessImport方法中创建一个新的AppDbContext实例,并将其传递给它吗?我看过DbContext不是线程安全的,所以这是一个好方法吗?
dependency-injection background-process entity-framework-core asp.net-core-mvc asp.net-core
我有以下Cypher Query,它在Neo4j 2.0.0中运行良好.
MATCH (ab:Point { Latitude: 24.96325, Longitude: 67.11343 }),(cd:Point { Latitude: 24.95873, Longitude: 67.10335 }),
p = shortestPath((ab)-[*..150]-(cd))
RETURN p
Run Code Online (Sandbox Code Playgroud)
Neo4jClient中的以下查询给出错误:功能评估超时.
var pathsQuery =
client.Cypher
.Match("(ab:Point { Latitude: 24.96325, Longitude: 67.11343 }),(cd:Point { Latitude: 24.95873, Longitude: 67.10335 }), p = shortestPath((ab)-[*..150]-(cd))")
.Return<IEnumerable<PointEntity>>("extract(n in nodes(p) : id(n))");
Run Code Online (Sandbox Code Playgroud)
和之后关于Xclave的另一个类似的工作:
http://geekswithblogs.net/cskardon/archive/2013/07/23/neo4jclient-ndash-getting-path-results.aspx
结果值为:功能评估超时.
var pathsQuery =
client.Cypher
.Match("(ab:Point { Latitude: 24.96325, Longitude: 67.11343 }),(cd:Point { Latitude: 24.95873, Longitude: 67.10335 }), p = shortestPath((ab)-[*..150]-(cd))")
.Return(p => new PathsResult<PointEntity>
{
Nodes = Return.As<IEnumerable<Node<PointEntity>>>("nodes(p)"),
}); …Run Code Online (Sandbox Code Playgroud) 未解决的highcharts datalabel动态旋转可能重复为列高
小提琴样本柱形图:http://jsfiddle.net/Yrygy/266/
有一些非常大的列和一个非常小的列.我想在大列中显示垂直旋转到-90度的白色标签,对于较小的列,我想在列顶部显示深灰色标签,旋转0度.
搞砸了之后,我实现了这个:http://jsfiddle.net/Yrygy/267/ 我可以根据格式化函数中的值更改标签的颜色,但是使用全局变量来获得对齐和旋转的权利不工作.
在这方面的任何帮助都会非常有帮助.我不能使用重复问题中建议的解决方案,因为我需要保持Y轴均匀并且不能设置MinPointLength.
最终守则:
var GlobalRotation = -90;
var GlobalAlign = 'right';
var X;
var Y;
$(function () {
$('#container').highcharts({
chart: {
type: 'column',
height: 700
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
plotOptions: {
column: {
stacking: 'normal',
pointPadding: 0,
groupPadding: 0.2,
dataLabels: {
enabled: true,
inside: false,
style: {
fontWeight: 'bold'
},
formatter: function() { …Run Code Online (Sandbox Code Playgroud) 我们可以使用jquery轻松删除类似的东西,但我们可以使用angular来做这样的事情吗?
<tr>
<td *ngFor="#lev of rubric?.criteria[0].levels">
<button class="close removeLevel" (click)="onClickRemove($event)">×</button>
<input type="text" class="form-control" placeholder="Performance Level"
#level="ngForm"
[(ngModel)]="lev.level"
ngControl="level"
/>
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)
在Component.ts中:
onClickRemove($event) {
}
Run Code Online (Sandbox Code Playgroud)
如何在此处访问行或单元元素,从哪里引发事件?
我按照这个教程和本教程和这一个,但我面临着同样的问题,最近3天。
我可以通过以下步骤正确设置主节点:
kubeadm init
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
export kubever=$(kubectl version | base64 | tr -d ‘\’)
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$kubever"
Run Code Online (Sandbox Code Playgroud)
一切似乎都很好
kubectl get all --namespace=kube-system
Run Code Online (Sandbox Code Playgroud)
然后,
在工作节点上:
kubeadm join --token 864655.fdf6d0b389867b79 192.168.100.17:6443 --discovery-token-ca-cert-hash sha256:a2d840808b17b53b9612e6271ccde489f13dbede7d354f97188d0faa9e210af2
Run Code Online (Sandbox Code Playgroud)
输出似乎很好,如下所示:
[preflight] Running pre-flight checks.
[WARNING FileExisting-crictl]: crictl not found in system path
[preflight] Starting the kubelet service
[discovery] Trying to connect to API Server "192.168.100.17:6443"
[discovery] Created cluster-info …Run Code Online (Sandbox Code Playgroud) 如何在我的C#应用程序中正确/标准地定义neo4j数据库的模式?
在我的应用程序中,我有节点属性和属性关系.我想定义这些节点和关系的模板/类,然后可以在运行时创建和关联这些节点和关系,并作为具有查询的类的对象进行检索.
经过大量的搜索和研究,我找到了与我的问题几乎相关的东西:http: //blog.micic.ch/net/using-neo4j-graph-db-with-c-net
但根据Neo4j文档,这些是遗留方法. https://github.com/Readify/Neo4jClient/wiki
那么Neo4J 2.0目前的标准方式是什么?因为我们现在也有标签.
我希望我的问题清楚.如果没有,请告诉我.
我的控制器中有一个创建操作。获取版本初始化绑定到如下视图中的表单的模型。
public ActionResult Create(int someId)
{
AppDbContext = new ApplicationDbContext();
ItemViewModel model = new ItemViewModel()
{
SomeId = someId
};
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
和 post 方法为
[HttpPost]
public async Task<ActionResult> Create(int someId, ItemViewModel model)
{
//Some Code Here
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
问题是我收到一个错误:
参数字典包含非空类型“System.Int32”的参数“someId”的空条目,用于方法“System.Threading.Tasks.Task`1[System.Web.Mvc.ActionResult] Create(Int32, SomeSystem.ViewModels .Admin.Some.SomeViewModel)' 中的“SomeSystem.Controllers.SomeController”。可选参数必须是引用类型、可为空类型或声明为可选参数。参数名称:参数
虽然我发帖前的网址看起来像:
SomeController/Create?someId=14
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
[HttpPost]
public async Task<ActionResult> Create(ItemViewModel model)
{
var myvar = model.SomeId; //SomeId is Null.
//Some Code Here
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
我假设,我在 Create Action 的 Get 方法中初始化的值应该在帖子中可用;但他们不是。
编辑:我的视图只是一个表格:
@model AuctionSystem.ViewModels.Admin.Item.ItemViewModel
@using …Run Code Online (Sandbox Code Playgroud) 我尝试了很多搜索,然后尝试了其他选项,但似乎没有任何效果。
我正在使用ASP.net Identity 2.0,并且具有UpdateProfileViewModel。更新用户信息时,我想将UpdateProfileViewModel映射到ApplicationUser(即,身份模型)。但是我想保留这些值,我是从用户数据库中获得的。即用户名和电子邮件地址,不需要更改。
我试着做:
Mapper.CreateMap<UpdateProfileViewModel, ApplicationUser>()
.ForMember(dest => dest.Email, opt => opt.Ignore());
Run Code Online (Sandbox Code Playgroud)
但是映射后我仍然将Email设置为null:
var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
user = Mapper.Map<UpdateProfileViewModel, ApplicationUser>(model);
Run Code Online (Sandbox Code Playgroud)
我也试过了,但是没有用:
public static IMappingExpression<TSource, TDestination> IgnoreAllNonExisting<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expression)
{
var sourceType = typeof(TSource);
var destinationType = typeof(TDestination);
var existingMaps = Mapper.GetAllTypeMaps().First(x => x.SourceType.Equals(sourceType) && x.DestinationType.Equals(destinationType));
foreach (var property in existingMaps.GetUnmappedPropertyNames())
{
expression.ForMember(property, opt => opt.Ignore());
}
return expression;
}
Run Code Online (Sandbox Code Playgroud)
然后:
Mapper.CreateMap<UpdateProfileViewModel, ApplicationUser>()
.IgnoreAllNonExisting();
Run Code Online (Sandbox Code Playgroud) asp.net automapper asp.net-mvc-5 asp.net-identity asp.net-identity-2
c# ×3
asp.net ×2
jquery ×2
neo4j ×2
neo4jclient ×2
angular ×1
asp.net-core ×1
asp.net-mvc ×1
automapper ×1
flannel ×1
highcharts ×1
javascript ×1
kubeadm ×1
kubernetes ×1
weave ×1