小编ajt*_*tum的帖子

什么是获得过去24小时T-SQL结果的最佳方法?

我正在为我的客户创建一个图表,他们想要在24小时,3天,1周,1个月等期间获得总客户数.老实说,我不是最好的SQL,所以生成这些查询并不是我的强项.

关于让客户超过24小时,我遇到了两个可能有效的"where"陈述,但我不确定哪个是最好的.

第一版:

WHERE DATEDIFF(hh,CreatedDate,GETDATE())>24
Run Code Online (Sandbox Code Playgroud)

第二版:

WHERE CreatedDate >= DATEADD(HH, -24, GETDATE())
Run Code Online (Sandbox Code Playgroud)

第一个版本生成21行,第二个生成17行(当然来自同一个数据集),所以显然一个比另一个更准确.我倾向于第一个,但我想你的意见......拜托.

谢谢,安德鲁

t-sql sql-server

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

在 dotnetcore 中添加到 Slack,而没有 Identity Framework 错误:oauth 状态丢失或无效

我正在尝试为我的 slackbot 创建一个非常简单的页面,以便用户可以登录和注册。但是,即使使用他们生成的“使用 Slack 登录”按钮时,我也会收到错误“oauth 状态丢失或无效。”。“添加到 Slack”也会发生同样的错误。

我的代码基于https://dotnetthoughts.net/slack-authentication-with-aspnet-core/。尽管它已经过时了,但它是我在网上能找到的唯一示例。我试图弄清楚我需要改变什么才能让它与 dotnetcore 3 和 Slack 2.0 一起工作,但我已经无能为力了。

在我的服务中,在调用 AddMvc 等之前,我有以下内容。

services.AddAuthentication(options =>
        options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme)
    .AddCookie(options =>
    {
        options.Cookie.Name = "MyAuthCookieName";
        options.Cookie.HttpOnly = true;
        options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
        options.Cookie.MaxAge = TimeSpan.FromDays(7);
        options.ExpireTimeSpan = TimeSpan.FromDays(7);

        options.LoginPath = $"/login";
        options.LogoutPath = $"/logout";
        options.AccessDeniedPath = $"/AccessDenied";
        options.SlidingExpiration = true;
        options.ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter;
    })
    //.AddSlack(options =>
    //{
    //    options.ClientId = Configuration["Slack:ClientId"];
    //    options.ClientSecret = Configuration["Slack:ClientSecret"];
    //});
    .AddOAuth("Slack", options =>
    {
        options.ClientId = Configuration["Slack:ClientId"];
        options.ClientSecret = Configuration["Slack:ClientSecret"]; …
Run Code Online (Sandbox Code Playgroud)

c# slack-api .net-core slack

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

尝试使用 JSON.Net 使用 SmartyStreets JSON ......“无法将 JSON 数组反序列化为类型组件”

我正在尝试使用 SmartyStreets JSON LiveAddress API,但遇到了一些困难。我承认我对 JSON 不太熟悉。无论如何,我尝试了几种不同的方法,但通常最终会出现错误“无法将 JSON 数组反序列化为元数据类型”。

这是 JSON 字符串:

[{"input_index":0,"candidate_index":0,"delivery_line_1":"1600 Amphitheatre Pkwy","last_line":"Mountain View CA 94043-1351","delivery_point_barcode":"940431351000","components":{"primary_number":"1600","street_name":"Amphitheatre","street_suffix":"Pkwy","city_name":"Mountain View","state_abbreviation":"CA","zipcode":"94043","plus4_code":"1351","delivery_point":"00","delivery_point_check_digit":"0"},"metadata":{"record_type":"S","county_fips":"06085","county_name":"Santa Clara","carrier_route":"C058","congressional_district":"14"},"analysis":{"dpv_match_code":"Y","dpv_footnotes":"AABB","dpv_cmra":"N","dpv_vacant":"N","ews_match":false,"footnotes":"N#"}}]
Run Code Online (Sandbox Code Playgroud)

我使用jsontocsharp webapp 来创建类。

这是我正在使用的代码:

using (var webClient = new WebClient())
        {
            var json = webClient.DownloadString("url");

            var md = JsonConvert.DeserializeObject<Metadata>(json);
            litTest.Text = md.county_name;
        }
Run Code Online (Sandbox Code Playgroud)

然后抛出我上面提到的错误。

任何帮助将不胜感激。

谢谢你,安德鲁

c# asp.net json json.net smartystreets

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

用于深度嵌套对象的自定义 Json 序列化程序

我有几个生成的 .NET 类,它们深入三层,我想以特殊格式序列化它们。因此,我开始使用 Newtonsoft.Json 编写自定义 Json Serializer。

我相信很难完全解释,所以我在这里发布了代码和目标:https : //dotnetfiddle.net/CDGcMW

本质上,有一个包含对象的初始数组,并且会有该对象的属性。困难的部分是这些属性是未知的,这就是我尝试创建自定义序列化程序的原因。

任何帮助我确定如何使此处生成的 Json https://dotnetfiddle.net/CDGcMW成为注释掉的“目标”JSON 将不胜感激。

编辑:将 dotnetfiddle 更新为较小的示例。原文在这里:https : //dotnetfiddle.net/dprfDu

.net c# serialization json json.net

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

How to get FFProbe to run using dotnet core as an Azure Function in Docker?

I am trying to get video details (length, height, width, and content type) from a video based on a URL. By using the nuget package https://www.nuget.org/packages/NReco.VideoInfo.LT I was able to create an Azure Function running locally pointing to my local install of FFProbe rather easily. However, the trick is now making it compatible with an Azure Function and, to the best of my knowledge, the easiest way to do that is by providing a Docker image that contains everything needed …

ubuntu azure docker .net-core azure-functions

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

如何使用 Flask 在 Heroku 中显示 stdout 日志?

在我的 Python 3.7.1 应用程序中,我使用 Flask 并将其部署到 Heroku,除了登录到 Heroku 控制台之外,一切正常。我搜索了答案,并认为我找到了一些......但可惜它们最终没有打印到 Heroku 日志控制台。当我在本地运行该应用程序时,使用“py app.py”它显示正常。

在我的 Procfile 中,我有以下内容:

web: gunicorn app:app --log-level debug --log-file=-
Run Code Online (Sandbox Code Playgroud)

在我的 app.py 文件中,我有以下内容:

if __name__ == '__main__':
    formatter = logging.Formatter( "%(asctime)s | %(pathname)s:%(lineno)d | %(funcName)s | %(levelname)s | %(message)s ")
    handler = RotatingFileHandler('logs/SlackBotApp.log', maxBytes=10000, backupCount=5)
    handler.setLevel(logging.DEBUG)
    handler.setFormatter(formatter)

    app.logger.addHandler(handler)
    app.logger.addHandler(logging.StreamHandler(stream=sys.stdout))
    app.logger.setLevel(logging.DEBUG)

    app.run()
Run Code Online (Sandbox Code Playgroud)

我像这样调用记录器:

app.logger.info("Url Requested: {}".format(url))
Run Code Online (Sandbox Code Playgroud)

我有一种感觉,我需要对我的 Procfile 进行修改,但我不确定是什么。有人可以提出任何建议吗?

python heroku flask gunicorn procfile

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

如何告诉 Swashbuckle 5 在 dotnetcore 3.0 中需要正文内容?

我正在尝试实现 Swashbuckle 5,并且我有几种方法可以像这样读取请求正文:

var requestBody = await Request.GetRawBodyStringAsync();
Run Code Online (Sandbox Code Playgroud)

我如何告诉 Swashbuckle/Swagger 将其作为参数读取,以便人们可以测试我的 API?我看到这里有人了一个非常相似的问题,但那是针对二进制内容和早期版本的 Swashbuckle。

任何帮助将不胜感激!

swagger swagger-ui .net-core swashbuckle asp.net-core-3.0

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