小编Dan*_*bes的帖子

SQLCMD模式下的ServerConnection.ExecuteNonQuery

我正在使用Microsoft Data-Tier Application框架来创建基于DacPackage对象的部署脚本.我试图使用Microsoft.SqlServer.Management.Smo.Server类来执行此脚本...

SqlConnection deployConnection = new SqlConnection(connBuilder.ToString());
deployConnection.Open();
Server server = new Server(new ServerConnection(deployConnection));
server.ConnectionContext.ExecuteNonQuery(deployScript);
Run Code Online (Sandbox Code Playgroud)

然而,这错误...

Unhandled Exception: Microsoft.SqlServer.Management.Common.ExecutionFailureException:
  An exception occurred while executing a Transact-SQL statement or batch. --->
  System.Data.SqlClient.SqlException: Incorrect syntax near ':'.
Run Code Online (Sandbox Code Playgroud)

我知道这个问题的答案是我需要处于SQLCMD模式,但我不知道如何告诉我的ServerConnection在所述模式下执行.

我想我的问题不像我在标题中说的那样具体.我真正需要做的是通过.Net框架执行从DacPackage生成的脚本.谁能帮我这个?

c# sql-server sqlcmd data-tier-applications sql-server-data-tools

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

Java - 将人类可读大小转换为字节

我发现了很多关于将原始字节信息转换为人类可读格式的信息,但我需要做相反的事情,即将字符串"1.6 GB"转换为长值1717990000.是否内置/良好 - 这样做的定义方式,还是我几乎不得不自己动手?

[编辑]:这是我的第一次刺...

static class ByteFormat extends NumberFormat {
    @Override
    public StringBuffer format(double arg0, StringBuffer arg1, FieldPosition arg2) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public StringBuffer format(long arg0, StringBuffer arg1, FieldPosition arg2) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Number parse(String arg0, ParsePosition arg1) {
        return parse (arg0);
    }

    @Override
    public Number parse(String arg0) {
        int spaceNdx = arg0.indexOf(" ");
        double ret = Double.parseDouble(arg0.substring(0, spaceNdx));
        String unit = arg0.substring(spaceNdx + …
Run Code Online (Sandbox Code Playgroud)

java byte human-readable long-integer

9
推荐指数
4
解决办法
5407
查看次数

Node.Js:资源解释为字体但使用MIME类型text/html传输

我的网站上的图标由Node.Js提供,不会呈现,我看到标题中指出的错误.我正在为我的服务器使用这个脚本... https://github.com/joeeames/AngularFundamentalsFiles/blob/master/web-server.js

第98行下面我添加了......

'woff':'application/font-woff'
Run Code Online (Sandbox Code Playgroud)

我也...

npm install mime
Run Code Online (Sandbox Code Playgroud)

但我所做的一切似乎都无效.有谁知道如何解决这个问题?控制台的具体错误是......

Resource interpreted as Font but transferred with MIME type text/html: "https://<my_site>/bower_components/font-awesome/fonts/fontawesome-webfont.woff?v=4.1.0".
Run Code Online (Sandbox Code Playgroud)

我看到TTF和SVG类型的类似错误.

mime node.js font-awesome

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

无法读取Angular Test Mock的属性'subscribe'

我正在尝试对具有注入服务的Angular组件进行单元测试.在组件的构造函数中,调用注入服务的方法,该方法返回Observable.我正在尝试在组件的单​​元测试中模拟服务,但我一直遇到这个错误:TypeError: Cannot read property 'subscribe' of undefined.

我试图通过以下方式模拟服务:

const serviceStub = {
  getObservable: () => { return {subscribe: () => {}}; },
};

beforeEach(async(() => {
  TestBed.configureTestingModule({
    providers: [
      {provide: MyService, useValue: serviceStub}
    ]
})


it('should create', () => {
  spyOn(serviceStub, 'getObservable').and.returnValue({subscribe: () => {}});
  expect(component).toBeTruthy();
});
Run Code Online (Sandbox Code Playgroud)

感觉我错过了一些明显的东西.有人可以指出来吗?

UPDATE

即使我在我的测试床提供商中注入实际服务,我也会收到此错误.

组件的构造函数看起来像这样:

private _subscription: Subscription;

constructor(private _service: MyService) {
  this._subscription = _service.getObservable().subscribe(console.log);
}
Run Code Online (Sandbox Code Playgroud)

dependency-injection mocking jasmine rxjs angular

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

链下工作人员和签名交易

据称,fn offchain_worker在块导入后,所有节点每次都会调用该函数。想象一下这样的情况:fn offchain_worker我们进行 http 调用以从远程服务器获取一些不确定的值,一旦获得结果,我们就调用签署pub fn onchain_callback交易以将该结果包含在区块链状态中。

如果在每个块导入后所有验证器都执行链下工作人员,那么我最终会得到每个验证器的一个新签名交易,并具有不同的结果(记住不是确定性的)。

例子。我的链下工作人员从远程服务器获取随机数并回调签署新交易的结果。如果我的网络中有 10 个验证者...问题:

1.- 我最终会得到 10 笔具有不同随机数的新交易?

2.- 它将仅由验证者执行,还是由连接到区块链的所有完整节点执行?

3.- 是否可以仅在块中包含某个外部因素时而不是在每次块导入后触发链下工作人员?

blockchain substrate

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

你好,世界!在Brainfuck

以下代码片段来自维基百科,是标准的Hello World的序言!在Brainfuck的程序...

1. +++++ +++++             initialize counter (cell #0) to 10
2. [                       use loop to set the next four cells to 70/100/30/10
3.    > +++++ ++              add  7 to cell #1
4.    > +++++ +++++           add 10 to cell #2 
5.    > +++                   add  3 to cell #3
6.    > +                     add  1 to cell #4
7.    <<<< -                  decrement counter (cell #0)
8. ]
Run Code Online (Sandbox Code Playgroud)

我理解这里发生的事情的要点,但我不明白的是第3到第6行发生的事情的机制.如果+++++ +++++在值中a[0]加10 ,为什么将指针递增1并执行++*ptr7次会导致a[1]等于70?不应该a[1] = 7 …

brainfuck

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

IIS Express似乎不会挑选对applicationhost.config的更改

我按照这个问题的接受答案,尝试通过我的机器上运行的IIS Express服务器在本地调试时,让我的.Net Web应用程序在一组特定的凭据下运行,但是,我似乎无法得到更改拾起.不可否认,我不知道如何验证实际发生的情况,但我看到的行为让我相信网络应用程序只是继续在我自己的Windows凭据下运行.我已经通过System Manager停止了IIS Express进程并重新启动了我的计算机,但没有骰子.这是我在applicationhost.config文件中的内容...

<applicationPoolDefaults managedRuntimeLoader="v4.0">
    <processModel userName="username" password="a_strong_pwd" />
</applicationPoolDefaults>
Run Code Online (Sandbox Code Playgroud)

.net asp.net web-applications iis-express visual-studio-2012

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

模式比较检测相同存储过程的差异

我使用Visual Studio 2012架构比较工具与Microsoft SQL Server DAC包文件(dacpac)区分实际数据库.期望是数据库和文件是"相等的".但是,模式比较报告BodyScript了三个存储过程的属性差异,所有这些过程都包含大量动态SQL.但令人沮丧的是,在对象定义的实际差异中,存储过程的定义之间没有明显的差异.此外,我们已将脚本复制到许多不同的diff工具中以查找空格类型差异,但看起来这两个脚本是二进制相同的.我们已经玩了很多架构比较选项(忽略空格,忽略关键字大小写等),但似乎没有什么能解决这个问题.

在研究这个问题时,我遇到了类似的问题,发布在Microsoft Connect上,也发布在StackOverflow上,但似乎这些问题尚未解决.有没有人对解决这个问题的其他方法有任何建议?

sql-server stored-procedures schema-compare visual-studio-2012 dacpac

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

调度另一个 Substrate FRAME Pallet 中定义的函数

我熟悉实现此问题标题中描述的目标的一种机制:在调用在另一个托盘中编写的外部(如 Sudo 托盘或实用程序托盘中定义的多重签名功能。跨托盘调度功能还有哪些其他选项?具体来说,我想将一个托盘(托盘 A)作为Trait另一个托盘(托盘 B)的绑定类型,然后从托盘 A 中分派在托盘 B 中定义的函数。

substrate

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

传递参数以进行延迟实例化

给定以下代码片段,如何将成员变量传递_tenantContextLazy<CloudBlobContainer>构造函数中?

public class BlobStorage : IStorage
{
    private readonly ITenantContext _tenantContext;

    public BlobStorage(ITenantContext tenantContext)
    {
        _tenantContext = tenantContext;
    }

    private readonly Lazy<CloudBlobContainer> _blobcontainer = new Lazy<CloudBlobContainer>(() =>
    {
        var connectionString = ConfigurationManager.ConnectionStrings["FileStorage"].ConnectionString;
        CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
        CloudBlobContainer blobContainer = blobClient.GetContainerReference("attachments");
        blobContainer.CreateIfNotExists();

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

c# parameter-passing lazy-initialization

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