小编Raj*_*Gan的帖子

Angular 创建垂直时间线

我想创建一个响应式垂直时间线,如下所示。抱歉,我是后端开发人员,CSS 方面不太强。

在此输入图像描述

我能够实现如下所示的目标

在此输入图像描述

目前,我正在寻求帮助将我的 div 左右定位,如图一所示。

我打算使用 bootstrap 和 fa Icon

我的CSS:

$text-color: #373737;
$gray-base: #494949;
$gray-darker: #222;
$gray-dark: #333;
$gray: #555;
$gray-light: #777;
$gray-lighter: #eee;
$brand-primary: #1f9eba;
$brand-success: #59ba1f;
$brand-info: #5bc0de;
$brand-warning: #d1bd10;
$brand-danger: #ba1f1f;

/* Timeline */
.timeline {
  list-style: none;
  padding: 20px;
  position: relative;
  &:before {
    top: 40px;
    bottom: 0;
    position: absolute;
    content: " ";
    width: 3px;
    background-color: #eeeeee;
    left: 50%;
    margin-left: -1.5px;
  }
  .timeline-item {
    margin-bottom: 20px;
    position: relative;
    &:before,
    &:after {
      content: "";
      display: table; …
Run Code Online (Sandbox Code Playgroud)

html css sass angular

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

使用自定义验证响应和流畅的验证

您好,我正在尝试使用.NET Core获得针对我的webApi的自定义验证响应。

在这里我想有一个响应模型

[{
  ErrorCode:
  ErrorField:
  ErrorMsg:
}]
Run Code Online (Sandbox Code Playgroud)

我有一个验证器类,目前我们只检查ModalState.IsValid验证错误,然后将模型状态对象作为BadRequest传递。

但是新要求要求我们为每个验证失败都具有ErrorCodes。

我的示例验证器类

public class TestModelValidator :  AbstractValidator<TestModel>{

public TestModelValidator {
   RuleFor(x=> x.Name).NotEmpty().WithErrorCode("1001");
   RuleFor(x=> x.Age).NotEmpty().WithErrorCode("1002");
  }
}
Run Code Online (Sandbox Code Playgroud)

我可以在操作中使用类似的方法以获得验证结果

选项1:

 var validator = new TestModelValidator();
    var result = validator.Validate(inputObj);
    var errorList = result.Error;
Run Code Online (Sandbox Code Playgroud)

并将操作ValidationResult操作到我的自定义响应对象。或
Opt2:

I can use [CustomizeValidator] attribute and maybe an Interceptors.
Run Code Online (Sandbox Code Playgroud)

但是对于Opt2,我不知道如何从拦截器到控制器操作检索ValidationResult。

我只想编写一个通用方法,这样就避免在每个控制器操作方法中调用Opt1进行验证。

要求指出正确的资源。

.net c# fluentvalidation asp.net-web-api asp.net-core

7
推荐指数
4
解决办法
5086
查看次数

Powershell:在 applicationHost.config 中查找 allowedServerVariables 检查重复项的脚本

我正在尝试添加一个新的服务器变量

Add-WebConfiguration /system.webServer/rewrite/allowedServerVariables -atIndex 0 -value @{name="HTTP_COOKIE"}
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误

Add-WebConfigurationProperty : Filename: 
Error: Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'Test'
At line:1 char:1
+ Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filt ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-WebConfigurationProperty], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.IIs.PowerShell.Provider.AddConfigurationPropertyCommand
Run Code Online (Sandbox Code Playgroud)

我可以使用 try catch 块进行抑制,但想检查变量是否已经存在,如果它已经存在则跳过添加。

谁能告诉我如何进行这项检查?

.net c# windows asp.net powershell

5
推荐指数
2
解决办法
1077
查看次数

C# .net Core Fluentvalidation手动验证获取验证器类实例

我试图获取验证器类实例,而不是在我的方法中手动启动。

我正在使用 Asp .net core webapi 2,我在启动类中注册我的验证器

services.AddMvc().AddFluentValidation().
Run Code Online (Sandbox Code Playgroud)

在我的一种操作方法中,我必须验证规则集。所以我在本地创建我的验证器类

var validator = new MyClassValidator()
var result = validator.Validate(obj,ruleSet: "RulesetName");
Run Code Online (Sandbox Code Playgroud)

我试图避免这种说法var validator = new MyClassValidator()。我想使用 IOC 并获取一个实例。有什么帮助吗?

c# validation fluentvalidation asp.net-web-api asp.net-core

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

Angular 7 Typescript - 服务 ErrorHandle 丢失对象实例

当我从 Service api 调用中获得 404 或 500 时,我试图显示错误消息 [ngBootstrap Alert]。

我想通过 alertComponent 显示错误,并使用服务进行数据共享 [AlertService.ts]。

当我调用 api 返回 404 时,我捕获错误并调用在我的服务基类中定义的 handleError 方法。

问题是我在我的基类中注入了我的警报服务,当我调用 HandleError 方法时,警报变量丢失了它的实例并设置为未定义。

基础服务.ts

@Injectable({
  providedIn: 'root'
})
export abstract class BaseService {

  constructor(msgService: AlertService) { }

  public handleError(httpErrorResponse: HttpErrorResponse) {

    console.log(httpErrorResponse);

    let errorMessage = '';
    switch (httpErrorResponse.status) {
      case 400:
        errorMessage = 'Bad Request detected; please try again later!';
        break;
     case 404:
        const errorMsg = new Alert(AlertType.Danger, 'tracking-not-found');
        this.msgService.Add(errorMsg);
        break;
      case 500:
        errorMessage = 'Internal Server Error; please …
Run Code Online (Sandbox Code Playgroud)

typescript angular

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

流畅的验证不适用于列表对象

我正在尝试验证 webApi 2 中的输入对象列表。

但它没有验证。Modelstate 始终设置为 true。

示例代码:

public class A
{
    public int Id { get; set; }
    public string Name { get; set; }
} 

public class ClassAValidator : AbstractValidator<A>
{
    public classAValidator()
    {
        RuleSet("ClassA",()=>{
            RuleFor(x => x.Id).NotEmpty().WithMessage("The Idcan't be Empty or Zero");
            RuleFor(x => x.Name).NotEmpty().Length(10).WithMessage("Name Should be Six Char length");
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

注意:字符串字段必须是 6 个字符。

应用程序编程接口:

 [HttpPut]
 public async Task<IHttpActionResult> Put([FromBody] List<A> alist)
 {
     if(!ModelState.IsValid) throw new InvalidDataException(ModelState,"Data Validation Failed for Upload Class A"); 
     // Model …
Run Code Online (Sandbox Code Playgroud)

c# asp.net fluentvalidation asp.net-web-api

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

Azure Cosmos DB 通过 C# 代码将集合 TTL 设置为 - on(无默认值)

我正在寻找一个选项来将我的 Cosmos DB 集合 TTL 设置为 ON 但没有默认值。

这里我想在文档级别控制过期时间。我看到如果我在集合级别设置默认时间,它将覆盖文档级别中提到的时间。如果我错了请纠正我。

基本上,我可以在数据资源管理器中设置它,但不确定如何通过 C# 代码进行设置。

从这个https://learn.microsoft.com/en-us/azure/cosmos-db/time-to-live

我发现我可以设置 -1(过期关闭)或 n 几秒来过期。

在此输入图像描述

.net c# azure azure-storage azure-cosmosdb

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

C# 字符串在所有样式或文化上转为十进制

您好,我想知道是否有更好的方法将字符串解析为涵盖各种格式的十进制

\n\n
    \n
  1. 1.30 美元
  2. \n
  3. \xc2\xa31.50
  4. \n
  5. \xe2\x82\xac2,50
  6. \n
  7. 2,50 \xc2\xa0\xe2\x82\xac
  8. \n
  9. 2.500,00 \xc2\xa0\xe2\x82\xac
  10. \n
\n\n

我看到很多使用文化来转换.& 的例子,。但就我而言,我没有任何东西可以识别这种文化。

\n\n

我从客户端获得这个显示字段,我需要提取该值。

\n\n

我尝试了以下方法(不适用于所有情况),但想知道我们是否有最好的方法来处理这个问题。

\n\n
Decimal.Parse(value,NumberStyles.Currency |\n                    NumberStyles.Number|NumberStyles.AllowThousands |\n                    NumberStyles.AllowTrailingSign | NumberStyles.AllowCurrencySymbol)\n
Run Code Online (Sandbox Code Playgroud)\n\n

我还尝试使用正则表达式删除货币符号,但无法在一种逻辑中同时转换 1.8 或 1,8。

\n

.net c# decimal c#-4.0

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

C#Async Foreach循环用于大量数据

我必须在批处理作业中处理大量数据

程序流程

var inputDataLst = contextObj.GetData(); //More that 10000 rows I will retrieve

foreach(var item in inpDataLst)
{
     //logic
}

Call context.SaveMethod(inpuDataLst);
Run Code Online (Sandbox Code Playgroud)

我想做点什么

var tsklst = inputDataLst.Select(async pItem => 
{
   //Logic
});

await Task.WhenAll(taskList);
Run Code Online (Sandbox Code Playgroud)

编译器发出警告,Resharper建议我制作同步方法.

任何人都可以建议我如何处理这个,因为我将有大量的数据,我想做一个异步操作..

实施@bruno建议

Parallel.ForEach(taskList, item => {
 item.StatusId = 2; //Completed
 LastUpdateUser = "Batch";
});
Run Code Online (Sandbox Code Playgroud)

循环完成后我得到taskList为NULL,

.net c# async-await parallel.foreach

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