小编Set*_*eth的帖子

MVC中模型的条件验证

我有一个视图和模型,我用于记录的编辑和插入页面.其中一个业务要求是编辑时需要某个字段,而不是新字段.最初在这个特殊功能被添加到文档之前,我有这样的模型:

[Required(ErrorMessage = "*")]
[Range(0.0, (double)decimal.MaxValue)]
[DisplayName("Cost")]
[DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
public decimal ProposedCost { get; set; }
Run Code Online (Sandbox Code Playgroud)

如果是插入表单,我想删除所需的属性,或者如果是编辑表单,则添加它.什么是更好的方法?我的所有其他验证都是如上所述完成的.或者我可以改变模型状态吗?思考?

编辑

我应该澄清的是,他们仍然被允许在新的成本上插入,只是不需要.

asp.net-mvc

16
推荐指数
1
解决办法
3万
查看次数

Java连接到azure事件中心:SunCertPathBuilderException

我不习惯java世界,所以我不确定我的问题是在我的Azure设置还是java设置上.尝试下面的教程后,我收到以下异常.

https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-java-get-started-receive-eph

Failure while registering:     
com.microsoft.azure.eventprocessorhost.EPHConfigurationException:   
Encountered error while fetching the list of EventHub PartitionIds: 
sun.security.validator.ValidatorException: PKIX path building failed: 
sun.security.provider.certpath.SunCertPathBuilderException: unable to find 
valid certification path to requested target
Run Code Online (Sandbox Code Playgroud)

在样本的这一行中发生异常:

 host.registerEventProcessor(EventProcessor.class, options).get();
Run Code Online (Sandbox Code Playgroud)

我做了教程的.NET版本没什么问题.在这种情况下发送和接收工作.任何见解?过去几天我一直在摸索,没有运气.

java azure azure-eventhub

10
推荐指数
1
解决办法
493
查看次数

Angular5:需要在从observable返回数据之前阻止ngbTooltip渲染

我是角度2+的新手,并继承了一个不完整的项目.我的目标是创建一个工具提示,检查特定字段的审计详细信息,并显示它们.一个例子可能是:

"Updated by Seth, on 8/18/18."
Run Code Online (Sandbox Code Playgroud)

为此,我创建了一个角度组件,通过服务传递所有相关信息.通过查看Web调试器,我可以看到服务调用正在运行.不幸的是,渲染的是带有以下不完整文本的工具提示:

 "updated by , " 
Run Code Online (Sandbox Code Playgroud)

这是我的组件模板.

<ng-template #tipContent>
<span *ngIf="loadCompleted">Updated By {{ auditDetail.updatedBy }}, {{ auditDetail.updatedAt | amTimeAgo }}</span>
</ng-template>
<i [ngbTooltip]="tipContent" (mouseenter)="refreshAuditDetail()" class="fas fa-info-circle fa-sm"></i>
Run Code Online (Sandbox Code Playgroud)

这是组件打字稿.

@Component({
 selector: 'audit-tooltip',
 templateUrl: './audit-tooltip.component.html',
 styleUrls: ['./audit-tooltip.component.css']
})
export class AuditTooltipComponent {
 @Input() plan: Plan;
 @Input() fieldName: string;
 auditDetail: AuditDetail;
 loadCompleted: boolean = false;

constructor(private planService: PlanService) { }

refreshAuditDetail() {
 var planId = this.plan.id;
 var fieldName = this.fieldName;
 var fieldValue = this.plan[this.fieldName];
 this.loadCompleted = false;


this.planService.getAuditDetails(planId, …
Run Code Online (Sandbox Code Playgroud)

tooltip observable rxjs ng-bootstrap angular

6
推荐指数
2
解决办法
841
查看次数

基于角色的默认启动视图

我已经能够找到几个基于角色的身份验证的示例,但这不是身份验证问题.我有三种用户类型,其中一种我希望有一个不同的默认起始页面.在用户信息可用之前初始化Route-config.

在坚果壳中:如果角色A或角色B从下面开始

Controller: Home 
Action: Index
Run Code Online (Sandbox Code Playgroud)

其他:

Controller: Other
Action: OtherIndex
Run Code Online (Sandbox Code Playgroud)

应该在何处以及如何实施?

编辑

这应该仅在第一次访问站点时发生,其他用户可以转到Home/Index,而不是默认情况下.

编辑

使用Brad的建议我使用他的重定向逻辑创建了一个重定向属性,并将其应用于Index.然后我为页面创建了另一个操作.这样,如果我确实需要允许访问HomeIndex,我可以专门为它分配Home/HomeIndex,任何使用默认路由的东西都可以访问Home/Index

[RedirectUserFilter]
public ActionResult Index()
{
     return HomeIndex();
}
Run Code Online (Sandbox Code Playgroud)

对于那些需要它的人 - 这是属性

 public class RedirectUserFilterAttribute: ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext actionContext)
        {

            if (!HttpContext.Current.User.IsInRole("Role A") 
            && !HttpContext.Current.User.IsInRole("Role B"))
            {
               actionContext.Result = new RedirectToRouteResult(
               new RouteValueDictionary {
                           { "Controller", "OtherController" }, 
                           { "Action", "OtherAction" } });
             }

          }
       }
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc asp.net-mvc-4

3
推荐指数
1
解决办法
1781
查看次数

Azure 函数 Blob 触发器 - 容器名称作为设置

我正在尝试创建一个 Azure 函数,该函数连接到一个非硬编码的容器,就像我的连接一样。

  public static void Run(
[BlobTrigger("Container-Name/ftp/{name}", Connection = "AzureWebJobsStorage")]Stream blobStream, 
string name, 
IDictionary<string, string> metaData, 
TraceWriter log)
Run Code Online (Sandbox Code Playgroud)

connection 属性能够直接从 local.settings.json 获取连接值。功能似乎不是“容器名称”的选项,或者如果是,则不是附加的 /ftp/{name}。

那么,有没有办法根据 Azure 函数 Blob 触发器的设置来设置容器名称?

azure azure-storage-blobs azure-functions

2
推荐指数
1
解决办法
993
查看次数

NGRX Store adapter.updateone 不更改更改检测的属性

我有以下减速器:

case ProductionCommentActionTypes.EditCommentSuccess: {
  return adapter.updateOne(action.payload, state);
}
Run Code Online (Sandbox Code Playgroud)

其中有效负载是以下对象:

{ 
    id: number,
    changes: { 
       id: number;
       avatar: string;
       createdAt: Date;
       createdBy: string;
       body: string;
       discipline: string;
       isConcern: boolean;
       isResolved: boolean;
       plan_Id: number;
       resolution: {
                    id: number;
                    comment_Id: number;
                    avatar: string;
                    createdAt: Date;
                    createdBy: string;
                    body: string;   
                   }
      }
}
Run Code Online (Sandbox Code Playgroud)

不幸的是,当我去更新对象时,我可以清楚地看到 action.payload 有我预期的数据。我已经检查了 action.payload 和效果:

  @Effect()
  resolveProductionConcernSuccess$: Observable<Action> = this.actions$
  .ofType<ResolveConcernSuccess>(ProductionCommentActionTypes.ResolveConcernSuccess).pipe(
    // Performing a get rather than an edit as the comment should have already 
    // been updated in the service …
Run Code Online (Sandbox Code Playgroud)

ngrx angular

1
推荐指数
1
解决办法
3243
查看次数