小编Krz*_*tof的帖子

在反序列化结果期间出现Elasticsearch.Net.UnexpectedElasticsearchClientException

我有一个ac#项目,我想向我的弹性搜索服务器发送请求。这是我的连接和弹性搜索客户端:

ConnectionSettings connectionSettings;
ElasticClient elasticClient;
connectionSettings = new ConnectionSettings(new 
Uri("http://192.168.2.197:9292/"));        
elasticClient = new ElasticClient(connectionSettings);
Run Code Online (Sandbox Code Playgroud)

这是我的要求:

var response = elasticClient.Search<NewsDataModel>(s => s
.Index("news-index")
.Type("title")
.Query(q => q.QueryString(qs => qs.Query("ny"))));
Run Code Online (Sandbox Code Playgroud)

这是我的模型:

public class NewsDataModel  {      
public string _id { get; set; }     
public string title { get; set; }     
public string content { get; set; }       
public string summary { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

但是当我发送请求时,我得到了这个异常:

Elasticsearch.Net.UnexpectedElasticsearchClientException:'无法将当前JSON对象(例如{“ name”:“ value”})反序列化为类型'System.Int64',因为该类型需要JSON基本值(例如,字符串,数字,布尔值,null)正确反序列化。要解决此错误,可以将JSON更改为JSON基本值(例如,字符串,数字,布尔值,null),或者更改反序列化类型,使其成为普通的.NET类型(例如,不像整数那样的原始类型,而不是集合类型) (例如数组或列表),可以从JSON对象反序列化。还可以将JsonObjectAttribute添加到类型中,以强制其从JSON对象反序列化。路径“ hits.total.value”,第1行,位置113。”

如何解决此异常?

c# elasticsearch nest

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

将数组传递给使用-File参数执行的PowerShell脚本

我有简单的脚本,它采用数组参数:

param(
    [Parameter(Mandatory=$true)]
    [string[]]$keys
)

for ($i = 0; $i -lt $keys.Length; ++$i) {
    Write-Host "$i. $($keys[$i])"
}
Run Code Online (Sandbox Code Playgroud)

我需要通过powershell和-File参数执行它(为了解决TeamCity错误),如下所示:

powershell.exe -File Untitled2.ps1 -keys a
Run Code Online (Sandbox Code Playgroud)

如何将参数作为数组传递给我的脚本?只要我传递单个键,它就可以正常工作,但它不想占用多个元素.

我试过跟随其他人:

powershell.exe -File Untitled2.ps1 -keys a,b
powershell.exe -File Untitled2.ps1 -keys:a,b
powershell.exe -File Untitled2.ps1 -keys $keys # where $keys is an array
Run Code Online (Sandbox Code Playgroud)

无论我尝试过什么,我都有"无法找到位置参数"错误,或者所有键都连接在第一个数组元素中.

有任何想法吗?

arrays parameters powershell

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

Visual Studio 中未加载源生成器依赖项

我正在研究源生成器,但我遇到依赖项问题:

It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'FileNotFoundException' with message 'Could not load file or assembly 'Flurl.Http, Version=3.0.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.'
Run Code Online (Sandbox Code Playgroud)

关于如何将依赖项打包到 nuget 中的信息有很多,但我直接引用分析器项目,如下所示:

<ProjectReference Include="SG.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
Run Code Online (Sandbox Code Playgroud)

在分析器项目中,我添加了<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>所有依赖项,并且所有依赖项都在输出目录中可用,但 VS 没有使用该目录 - 它使用了该目录,AppData\Local\Temp\VBCSCompiler\AnalyzerAssemblyLoader\[...]并且只在那里复制一个 DLL。

可以采取什么措施来实现这一目标?

.net c# sourcegenerators

9
推荐指数
2
解决办法
3303
查看次数

Angular附加父属性值

我有像这样的分层数据:

[  
    {  
        "children":[  
            {  
                "children":[...],
                [...]
            },
            {  
                "children":[...],
                [...]
            },
        ],
        [...]
    }
]
Run Code Online (Sandbox Code Playgroud)

我想通过展平数据来构建树状网格.我使用以下指令:

app.directive('tree', function (hierarchyService, logger, $timeout) {
    return {
        scope: {
            data: '='
        },
        restrict: 'E',
        replace: true,
        template: '<div>' +
            '<table class="table table-striped table-hover">' +
            '    <thead>' +
            '        <tr>' +
            '            <th class="col-md-6">Account name</th>' +
            '        </tr>' +
            '        </thead>' +
            '        <tbody><tr collection data="data" /></tbody>' +
            '    </table>' +
            '</div>'
    };
});

app.directive('collection', function() {
    return {
        restrict: "A",
        replace: true, …
Run Code Online (Sandbox Code Playgroud)

javascript hierarchy angularjs angularjs-directive

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

在单个GridPanel中使用PagingToolbar和CheckboxSelectionModel

我在Sencha论坛上发布了这个帖子,想在这里发布以防万一:

我有一个使用PagingToolbar和CheckboxSelectionModel的GridPanel.我想跟踪跨页面的选择.我差不多了,但是我遇到了PagingToolbar控件(例如下一页)在我的选择模型上触发'selectionchange'事件的问题.

这是我的代码的简化示例:

码:

var sm = Ext.create('Ext.selection.CheckboxModel', {
    listeners:{
        selectionchange: function(selectionModel, selectedRecords, options){
            console.log("Selection Change!!");
            // CODE HERE TO KEEP TRACK OF SELECTIONS/DESELECTIONS
        }
    }
});

var grid = Ext.create('Ext.grid.Panel', {
    autoScroll:true,
    store: store,
    defaults: {
        sortable:true
    },
    selModel: sm,
    dockedItems: [{
        xtype: 'pagingtoolbar',
        store: store,
        dock: 'bottom',
        displayInfo: true
    }],
    listeners: {'beforerender' : {fn:function(){
        store.load({params:params});

    }}}
});
store.on('load', function() {
    console.log('loading');
    console.log(params);
    console.log('selecting...');
    var records = this.getNewRecords();
    var recordsToSelect = getRecordsToSelect(records);
    sm.select(recordsToSelect, true, true);
});
Run Code Online (Sandbox Code Playgroud)

我假设我可以选择加载事件的记录而不触发任何事件.

这里发生的是在更改数据页面时触发selectionchange事件,我不希望发生这种情况.理想情况下,只有用户点击才会被跟踪为"selectionchange"事件,而不是任何其他组件的事件冒泡并在我的选择模型上触发事件.查看源代码,我可以看到在PagingToolbar上触发的唯一事件是"更改".我试图按照GridPanel,TablePanel,Gridview等处理它的方式,但我只是没有看到事件的路径.即使这样,我也不确定如何抑制从PagingToolbar到SelectionModel的事件.

先谢谢你,汤姆

extjs event-handling extjs4

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

当请求通过反向代理时,.NET Core 应用程序中的方案不正确

我有 apache 作为反向代理。apache的背后是.NET core应用程序。两者都使用 HTTPS。问题是,当我通过代理访问此 .NET 应用程序时,.NET 报告该请求是使用 http 在没有 SSL 的情况下发出的。

Apache 代理配置:

SSLProxyEngine on
<Location "/">
    ProxyPass "https://domain:8444/"
    ProxyPassReverse "https://domain:8444/"
</Location>
Run Code Online (Sandbox Code Playgroud)

Apache 可以通过https://domain/访问。

当我通过https://domain:8444/地址访问应用程序时,然后httpContext.Request.IsHttps==truehttpContext.Request.Scheme=="https",但是当我通过https://domain/访问应用程序时,然后httpContext.Request.IsHttps==falsehttpContext.Request.Scheme=="http"

当我尝试使用 PHP 进行相同的配置时,一切正常。有什么我可以做的吗?

.net apache reverse-proxy asp.net-core

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

如何按组件名称查询包含字符串某些部分的组件

我想用来Ext.ComponentQuery.query()查询包含一些名称路径的按钮名称.

假设我有4个按钮,名称声明为'edit_btn','add_btn','add2_btn'和'edit2_btn'

然后我使用查询. Ext.ComponentQuery.query("button[name='*edit*']");

我应该得到''edit_btn' '和''edit2_btn' '按钮.

Ext.ComponentQuery.query("button[name='*add*']");

我应该得到''add_btn' '和'add2_btn'按钮.

或者我可以在Ext.ComponentQuery.query()命令中使用正则表达式?

如果可以,如何使用它?

extjs extjs4

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

在Extjs 4的商店上加载监听器不起作用

我在Extjs 4中寻找像'加载'商店监听器这样的东西,但我遇到了一些问题.

1)我的印象是'load'监听器方法的'success'参数告诉我们操作是否成功,但'success'参数包含一个数组.我不知道该数组包含什么,但在调用'success.length'属性后,我发现它包含我的服务器端代码作为响应发送的实际行数.所以我认为'成功'属性实际上包含我的数据,但我不确定.

2)如果我对'records'或'success'参数使用Ext.each()方法,我无法看到加载的实际数据.如何查看实际数据?

商店代码如下:

Ext.define('myCompany.store.customerDistribution', {
    extend: 'Ext.data.TreeStore',
    autoLoad: true,

    proxy: {
        type: 'ajax',
        url: 'data/customerDistribution/customerCount.json',
        reader: {
            type: 'array',
            root: 'resultset'
        }
    },
    listeners: {
        load: function(store, records, success) {
            /*console.log('store - ' + store +
                        ', typeof(store) - ' + typeof(store) +
                        ', records - ' + records +
                        ', records data - ' + records.data +
                        ', success - ' + success +
                        ', type of success - ' + typeof(success)+
                        ', success length - ' …
Run Code Online (Sandbox Code Playgroud)

extjs store listener extjs4

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