小编Fil*_*ges的帖子

如何在执行完成后立即终止sqlcmd?

我在C#中创建一个进程来执行sqlcmd /S <servername> /d <dbname> /E /i以运行创建表,视图和存储过程的sql脚本.

问题是进程在执行完成后没有终止.我想知道如何在操作完成后立即终止sqlcmd.

sqlcmd是否有任何输入参数可以指定立即终止进程,还是可以直接在C#中进行?

更新

这是我用来执行进程的C#代码.

foreach (var file in files)
{
    ////var begin = DateTime.Now;
    ////context.TrackBuildWarning(string.Format("Start exec sql file at {0}.", DateTime.Now));

    Process process = new Process();
    process.StartInfo.UseShellExecute = false;
    process.StartInfo.RedirectStandardOutput = true;
    process.StartInfo.RedirectStandardError = true;
    process.StartInfo.CreateNoWindow = true;
    process.StartInfo.FileName = "sqlcmd.exe";
    process.StartInfo.Arguments = string.Format("-S {0} -d {1} -i \"{2}\" -U {3} -P {4}", sqlServerName, databaseName, file, sqlUserName, sqlPassword);
    process.StartInfo.WorkingDirectory = @"C:\";
    process.Start();
    process.WaitForExit(); // if I comment out this code it …
Run Code Online (Sandbox Code Playgroud)

c# batch-file sqlcmd

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

是否可以将.NET Core应用程序作为Windows服务和Linux deamon运行

是否有可能使用相同的代码创建一个.NET Core应用程序,可以作为Windows服务和Linux上的deamon运行?

你有一个例子/概念证明吗?

.net daemon windows-services .net-core

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

定义流文字类型时使用外部常量

我想在流文字类型中使用包中的导入常量并静态检查开关;

有没有办法做到这一点?(例子下面)

// action/types.js
import { REHYDRATE } from 'redux-persist/constants'

export type FooBar = {
  foo: number,
  bar: string,
};

export type Action
  = { type: 'FETCH_REQUEST', data: FooBar[] }
  | { type: REHYDRATE, payload: any } // <== this do not work
  ;

// reducer.js
import { REHYDRATE } from 'redux-persist/constants'

export default function (state: State = initialState, action: Action) 
    switch (action.type) {
    case 'FETCH_REQUEST': 
        // do something with action.data
    case REHYDRATE: { // <= flow says: uncovered code …
Run Code Online (Sandbox Code Playgroud)

javascript flowtype

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

在索引之上缓慢的MongoDB查询

我在MongoDB中有一个包含1,700万个文档的集合,每个文档的平均大小为6kb.该数据库位于合理的机器中,具有6Gb RAM和4个内核

此集合具有支持我的查询的索引.该索引具有bellow(String,String和Date)属性,大小仅为15mb.(在MongoDB Compass中验证)

{
    "Unit" : 1.0,
    "VendorCode" : 1.0,
    "EmissionDate" : 1.0
}
Run Code Online (Sandbox Code Playgroud)

但是,当我对集合运行以下查询时,返回需要很长时间.

db.Collection.find({
        'Unit': '016406',
        'EmissionDate': {$gte: new ISODate('2018-08-01')}
    }, {
        'Unit': 1,
        'VendorCode': 1,
        'EmissionDate': 1
    })
Run Code Online (Sandbox Code Playgroud)

根据我对SQL数据库的经验,在此大小的索引之上的此类查询将立即返回.但是,当我在MongoDB上运行它时,通过机器中的shell或Robo3T,它需要10多分钟才能完成!

我的感觉是,当查询找到文档时,由于某种原因,Mongo正在从存储中检索它.但这只是猜测.

我忘了考虑MongoDB的一些基本最佳实践吗?您可以给我哪些想法来调查这个问题?

performance mongodb

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