小编Fra*_*nva的帖子

WinForm:如何专门停靠在屏幕的一侧

经过几个小时的搜索,我仍然没有找到解决方案.

通过说独家对接我的意思是它占用屏幕的一部分(左,右,上或下),其余的其他程序不能使用该部分.如果你有Windows 8,它看起来像Win8中2个分区的一小部分.

我有WPF的解决方案,但现在我需要在WinForm的基础上做到这一点.

提前致谢.

c# winforms

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

无法使用 MemoryCache 访问已释放的对象

我收到此消息:

System.ObjectDisposeException:无法访问已处置的对象。导致此错误的一个常见原因是处置从依赖项注入解析的上下文,然后尝试在应用程序的其他位置使用相同的上下文实例。如果您在上下文上调用 Dispose() 或将上下文包装在 using 语句中,则可能会发生这种情况。如果您使用依赖项注入,则应该让依赖项注入容器负责处理上下文实例。

控制器:

    [HttpGet]
    public IActionResult GetAllTags()
    {
        try
        {
            return Ok(GetAll());
        }
        catch(Exception ex)
        {
            return ControllerHelper.LogAndReturnBadRequest(_logger, ex);
        }
    }

    private IEnumerable<TagDto> GetAll()
    {
            IEnumerable<TagDto> tags;
            if (!_cache.TryGetValue(CacheKeys.States, out tags))
            {
                tags = _service.GetAll()?.Select(t => _mapper.Map<TagDto>(t));

                if(tags != null)
                    _cache.Set(CacheKeys.States, tags);
            }

            return tags;
    }
Run Code Online (Sandbox Code Playgroud)

启动.cs

services.AddMemoryCache();

我正在逐行调试代码,但即使在代码的最后一行之后,也根本没有错误。

我看到的错误是在 Kestrel 控制台中。值得注意的是,该错误仅在从 _cache 获取标签时发生,而在第一次直接从数据库获取标签时不会发生。

在此输入图像描述

这是我从邮递员请求中得到的信息:

在此输入图像描述

许多类似的问题都涉及 dispose 对象,但在这里您可以看到我的代码中没有 dispose() 或 using() 。

c# entity-framework-core asp.net-core

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

我应该在神经网络中转置特征或权重吗?

我正在学习神经网络。

这是完整的代码: https://github.com/udacity/deep-learning-v2-pytorch/blob/master/intro-to-pytorch/Part%201%20-%20Tensors%20in%20PyTorch%20 (练习).ipynb

当我转置特征时,我得到以下输出:

import torch
def activation(x):
    return 1/(1+torch.exp(-x))

### Generate some data
torch.manual_seed(7) # Set the random seed so things are predictable

# Features are 5 random normal variables
features = torch.randn((1, 5))
# True weights for our data, random normal variables again
weights = torch.randn_like(features)
# and a true bias term
bias = torch.randn((1, 1))

product = features.t() * weights + bias
output = activation(product.sum())
Run Code Online (Sandbox Code Playgroud)

张量(0.9897)

但是,如果我转置权重,我会得到不同的输出:

weights_prime = weights.view(5,1)
prod = torch.mm(features, weights_prime) + bias …
Run Code Online (Sandbox Code Playgroud)

python machine-learning neural-network pytorch

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

SQL - 如何计算每天一行中每个状态的记录?

更新2

对不起,我忘了提,我只需要日期部分,而FormUpdated不是所有部分.


我有一张桌子 Sales

Sales
--------
id
FormUpdated
TrackingStatus
Run Code Online (Sandbox Code Playgroud)

有几种状态,例如Complete,Incomplete,SaveforLater,ViewRates等.

我希望在过去8天(包括今天)中以此表格获得我的结果.

预期结果:

Date Part of FormUpdated, Day of Week, Counts of ViewRates, Counts of Sales(complete), Counts of SaveForLater
--------------------------------------
2015-05-19   Tuesday    3   1   21  
2015-05-18   Monday     12  5   10
2015-05-17   Sunday     6   1   8
2015-05-16   Saturday   5   3   7 
2015-05-15   Friday     67  5   32
2015-05-14   Thursday   17  0   5 
2015-05-13   Wednesday  22  0   9
2015-05-12   Tuesday    19  2   6
Run Code Online (Sandbox Code Playgroud)

这是我的SQL查询: …

sql t-sql sql-server sql-server-2008 sql-server-2012

4
推荐指数
2
解决办法
5596
查看次数

在Gatsbyjs(Reactjs)项目中加载Google Place API

我正在尝试使用Google Place API的自动完成地址服务。

找到了这个库:https : //github.com/kenny-hibino/react-places-autocomplete#load-google-library

它要求在我的项目中加载库:https : //github.com/kenny-hibino/react-places-autocomplete#getting-started

如果它是纯Reactjs项目,我会在public / index.html中进行。但是,每次运行时,Gatsbyjs项目中的public / index.html都会被删除并重新生成:

Gatsby develop
Run Code Online (Sandbox Code Playgroud)

命令行。

如何在Gatsbyjs项目中使用Google Place API?

更新资料

我尝试了两种方法来实现这一目标。

  1. 在/layouts/index.js中使用React-Helmet,如下所示:

        <Helmet>
          <script src="https://maps.googleapis.com/maps/api/js?key={API}&libraries=places&callback=initAutocomplete" async defer></script>
        </Helmet>
    
    Run Code Online (Sandbox Code Playgroud)

    在此处输入图片说明

  2. 将脚本引用放在/public/index.html中,如下所示:

    <!DOCTYPE html>
    <html>
    
    <head>
        <meta charSet="utf-8" />
        <meta http-equiv="x-ua-compatible" content="ie=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
        <title data-react-helmet="true"></title>
        <script src="/socket.io/socket.io.js"></script>
        <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key={API_KEY}&libraries=places" async defer ></script>
    </head>
    
    <body>
        <div id="___gatsby"></div>
        <script src="/commons.js"></script>
    </body>
    
    </html>
    
    Run Code Online (Sandbox Code Playgroud)

对于第一种解决方案,每次刷新页面后,项目都会引发错误,要求加载Google JavaScript Map API。

对于第二种解决方案,每次我通过命令行重新启动Gatsby之后: gatsby develop

它重新生成index.html,刷新掉其中的JavaScript参考。

google-maps-api-3 google-places-api reactjs gatsby

4
推荐指数
2
解决办法
1493
查看次数

VS 2012 中的智能感知中的向下箭头是什么意思

在此输入图像描述

正如您所看到的红色矩形中的向下小箭头。这是否意味着该方法已被废弃?

如果是,那么最新的更新是什么?

例如,我想在 Razor 页面上使用文本框,但似乎所有输入组件都已标记为已废弃。

迷茫~~~~~~

如果有人可以提供一个链接来说明 Microsoft 网站上的所有这些字形,那就更好了。

谢谢。

visual-studio visual-studio-2012

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

如何测试我的web api方法

我有一个web api方法:

 [HttpPost, ActionName("GET")]
        public string Get(string apiKey, DateTime start, DateTime end)
        {
            var user = db.Users.SingleOrDefault(u => u.Id == apiKey);

            if (user == null)
            {
                return string.Empty;
            }

            var records = db.Histories.Where(h => h.Date >= start && h.Date <= end);
            return JsonConvert.SerializeObject(records);
        }
Run Code Online (Sandbox Code Playgroud)

这是我试图调用该方法的URL,但它没有达到该方法.

http://localhost:11847/api/History/Get?apiKey=398cfa9b-8c5c-4cf4-b4f3-8904a827ff22&start=2014-01-01&end=2014-12-01
Run Code Online (Sandbox Code Playgroud)

我也改变了WebApiConfig.cs

   config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}",
                defaults: new { id = RouteParameter.Optional }
            );
Run Code Online (Sandbox Code Playgroud)

从"api/{controller}/{id}到"api/{controller}/{action}

请帮忙.谢谢

asp.net-web-api asp.net-web-api2

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

如何使用 FluentAssertions 在 XUnit 中测试 MediatR 处理程序

我正在使用 XUnit 来测试我的 ASP.NET Core 2.2 项目。

与此同时,我在测试项目中有 FluentAssertions。

我想要做的是测试我的 MediatR 处理程序。

在这个处理程序中,我有 API 调用。

我已经阅读了文章,似乎我需要先设置fixture,但我发现代码并不容易让我遵循。

我的处理程序看起来像:

     public class GetCatsHandler : IRequestHandler<GetCatsQuery, GetCatsResponse>
{
    private readonly IPeopleService _peopleService;

    public GetCatsHandler(IPeopleService peopleService)
    {
        _peopleService = peopleService;
    }

    public async Task<GetCatsResponse> Handle(GetCatsQuery request, CancellationToken cancellationToken)
    {
        var apiResponse = await _peopleService.GetPeople();
        List<Person> people = apiResponse;

        var maleCatsGroup = GetCatsGroup(people, Gender.Male);
        var femaleCatsGroup = GetCatsGroup(people, Gender.Female);

        var response = new GetCatsResponse()
        {
            Male = maleCatsGroup,
            Female = femaleCatsGroup
        };

        return response;
    }

    private …
Run Code Online (Sandbox Code Playgroud)

c# xunit fluent-assertions mediatr asp.net-core

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

反序列化时如何忽略下划线

我们有类似 Golang 有 json 注释的东西吗?

type FieldType struct {
    TypeName      string          `json:"typeName"`
    CodeType      string          `json:"codeType"`
    Suffix        string          `json:"suffix"`
    PropertiesRaw json.RawMessage `json:"properties"`
    Properties    FieldTypePropertyMap
}
Run Code Online (Sandbox Code Playgroud)

我有一个 json 字符串:

{“long_name”:“dffdf”}

我的课:

public class Result
{
  public int LongName {get; set;}
}
Run Code Online (Sandbox Code Playgroud)

由于下划线,LongName 始终为空,我不想在我的类属性中使用下划线。

反序列化时是否可以选择忽略下划线?

c# json json.net

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

如何使用 ffmpeg 将 WebM 音频(Opus)和 MP4 视频(H.264)合并为一个 MP4 文件

我正在尝试将 WebM 文件与 Opus 音频 + 带有 H.264 视频的 MP4 文件合并到 MP4 文件中:

ffmpeg -i audio.webm -i video.mp4 -c copy output.mp4
Run Code Online (Sandbox Code Playgroud)

但是,我收到一个错误:

[mp4 @ 0x56105a6d0a40] opus in MP4 support is experimental, add '-strict -2' if you want to use it.
Could not write header for output file #0 (incorrect codec parameters ?): Experimental feature
Run Code Online (Sandbox Code Playgroud)

完整日志:

ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.3.0 (Arch Linux 9.3.0-1)
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl …
Run Code Online (Sandbox Code Playgroud)

video ffmpeg

3
推荐指数
2
解决办法
5597
查看次数