小编Dra*_*lut的帖子

TWS Interactive Brokers API-如何解决“未为请求找到安全定义”?

使用Java API(我猜想这适用于任何其他TWS Interactive Brokers客户端API),出现错误“未为请求找到安全定义”。FAQ和其他资源毫无帮助。

    Contract contract = new Contract();

    int id = incId;           

    System.out.println("Oder Id " + id );

    // use UTC seconds as transaction id

    // This is the problem you need to have a blank contractId
    contract.m_conId = 12345;
    contract.m_symbol = signal.symbol;
    contract.m_secType = "STK";
    contract.m_expiry = "";
    contract.m_strike = 0;
    contract.m_exchange = "SMART";
    contract.m_primaryExch = "ISLAND";
    contract.m_currency = "USD";

    //etc

    Order order = new Order();

    // set order fields
    order.m_account = "XXXXXX";
    order.m_orderId = id;
    //etc

    GetInstance().wrapper.m_client.placeOrder(id, …
Run Code Online (Sandbox Code Playgroud)

java api tws interactive-brokers

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

从更大的TimeSpan中减去TimeSpan不同年份

我使用的语言是C#.

我有下面的dillema.

DateTime A,DateTime B.如果A <B,那么我必须计算该时间跨度内每年的天数,并乘以与该年相对应的系数.我的问题是它可以跨越多年.

例如:

Ned of Time in TimeSpan for 2009*coef for 2009 + Nr of Time in TimeSpan for 2010*coef for 2010 + etc

c# asp.net algorithm math

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

reqExecutions IBrokers包

有人可以为我提供reqExecutions的工作示例吗?我在使用ewrapper和回调机制时遇到了困难.在搜索谷歌的工作示例后,我无法掌握任何简单的工作.请注意,我不是程序员,这就是为什么很难让我的头脑缠绕在ewrapper和回调上.

r ibrokers interactive-brokers

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

使用 EPPLUS C# 创建 Excel XLSX 文件的 ZipArchive

我有以下函数可以FileStreamResult为我的 ASP.NET MVC 应用程序返回 a 。

/// <summary>
/// Generates a FileStreamResult containing a zip file with the EXCEL file in it
/// </summary>
/// <typeparam name="T">Type of object in the object list parameter</typeparam>
/// <param name="objectList">The object list enumerable. This contains the data for the EXCEL file</param>
/// <param name="fileName">The file name of the EXCEL</param>
/// <returns>FileStreamResult</returns>
public FileStreamResult CreateZipFileFileStreamResult<T>(IEnumerable<T> objectList, string fileName)
{   
    var ms = new MemoryStream();

    var contentType = System.Net.Mime.MediaTypeNames.Application.Zip;

    ExcelPackage excelPackage = null; …
Run Code Online (Sandbox Code Playgroud)

c# excel zip archive epplus

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

如何加载自定义字体以在Windows Azure上绘制图像?

我需要使用自定义字体在我自己的应用程序上绘图.

是否可以通过部署脚本进行安装?

c# fonts azure

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

根据数据类型在MVC 3中自动生成HTML属性

我在MVC模型中有以下属性:

[Range(0, double.MaxValue, ErrorMessage = "The Volume must have positive values!")]       
public decimal? Volume { get; set; }
Run Code Online (Sandbox Code Playgroud)

生成的HTML是

<input type="text" value="1,00" name="Product.Volume" id="Product_Volume" data-val-range-min="0" data-val-range-max="1.79769313486232E+308" data-val-range="The Volume must have positive values!" data-val-number="The field Volume must be a number." data-val="true" class="text-box single-line">
Run Code Online (Sandbox Code Playgroud)

如何使生成的HTML成为这样的:

<input type="text" value="1,00" name="Product.Volume" id="Product_Volume" data-val-range-min="0" data-val-range-max="1.79769313486232E+308" data-val-range="The Volume must have positive values!" data-val-number="The field Volume must be a number." data-val="true" class="text-box single-line" data-type="decimal" >
Run Code Online (Sandbox Code Playgroud)

不同的是额外的 data-type="decimal"

我希望自动添加HTML属性,因此我不必手动添加它.

.net c# asp.net-mvc razor asp.net-mvc-3

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

在C#中从ATR确定设施代码和卡号

我有以下读卡器HID Omnikey 5325.我有一张名为HIS Proximity的非接触式卡.

此卡上写的号码是1 33593 42101044091-3.

通过读卡,我得到以下ATR十六进制:3B050002F10673

使用以下应用程序,我设法看到以下信息.

PACS探针 你好Prox

我需要提取设施代码代码以识别卡.

我设法找到以下代码,但我遗漏了几件:

/// <summary>
    /// Extract a data item from the Wiegand raw data. The data item usually is something like a card 
    /// number or facility code.
    /// </summary>
    /// <param name="format"></param>
    /// <param name="identifier"></param>
    /// <returns></returns>
    public int getData(int format, int identifier)
    {
        int byteOffset = 0;
        if (m_rawWiegandData == null)
        {
            throw new Exception("no raw Wiegand data available");
        }
        //SELF-TEST
        byte[] testData_H10301 = …
Run Code Online (Sandbox Code Playgroud)

.net c# bytearray smartcard winscard

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

ASP.NET Core 无法使用 RazorViewEngine 按路径找到 cshtml 文件

我想cshtml在我的 ASP.NET Core 2.1 Web API 项目中找到我的文件。为此,我正在使用以下代码:

var httpContext = new DefaultHttpContext { RequestServices = this.serviceProvider };
var actionContext = new ActionContext(httpContext, new RouteData(), new ActionDescriptor());

var viewResult = this.razorViewEngine.FindView(
                actionContext,
                "~/PdfTemplate/ProjectRaport.cshtml",
                false);
Run Code Online (Sandbox Code Playgroud)

该文件在这里:

在此处输入图片说明

但是从上面的代码来看,View(即~/PdfTemplate/ProjectRaport.cshtml)为空。

如何通过路径查找特定文件WebApi Core

这段代码工作正常:

var viewResult = this.razorViewEngine.FindView(actionContext,
                Path.Combine(this.hostingEnvironment.ContentRootPath, "PdfTemplate", "ProjectRaport.cshtml"),
                false);
Run Code Online (Sandbox Code Playgroud)

文件的路径是确定的,但ViewviewResult仍然是空

当我尝试GetView

var viewResult = this.razorViewEngine.GetView(
                Path.Combine(this.hostingEnvironment.ContentRootPath, "PdfTemplate", "ProjectRaport.cshtml"),
                Path.Combine(this.hostingEnvironment.ContentRootPath, "PdfTemplate", "ProjectRaport.cshtml"),
                false);
Run Code Online (Sandbox Code Playgroud)

viewResult.View仍然为空

编辑

SearchedLocations路径中是可以的: …

c# razor asp.net-core asp.net-core-2.1

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

C# 使用 linq 查找字符串的最大值

这就是我所拥有的,它一直返回 null。

当我添加 where 语句时,它无法识别 Convert.toInt32

var maxTopID = (from max in dbcontext.Topics.Local
               select max.TopicID).Max();
Run Code Online (Sandbox Code Playgroud)

c# linq string max

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

使用 (var connection = new SqlConnection("ConnectionString")) 是否仍然关闭/处理错误连接?

我有以下代码

try
{
    using (var connection = new SqlConnection(Utils.ConnectionString))
    {
        connection.Open();

        using (var cmd = new SqlCommand("StoredProcedure", connection))
        {                            
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            var sqlParam = new SqlParameter("id_document", idDocument);
            cmd.Parameters.Add(sqlParam);

            int result = cmd.ExecuteNonQuery();
            if (result != -1)
                return "something";

            //do something here

            return "something else";
        }
    }

    //do something
}
catch (SqlException ex)
{
    return "something AKA didn't work";
}
Run Code Online (Sandbox Code Playgroud)

问题是:var connection如果using括号 ( { })之间发生意外错误,是否仍然关闭?

问题是我对存储过程的大部分调用都是这样进行的,最近我收到了这个错误:

System.InvalidOperationException:超时已过期。在从池中获取连接之前超时时间已过。这可能是因为所有池连接都在使用中并且达到了最大池大小。

我访问数据库的另一种方式是通过 nHibernate。

.net c# t-sql sql-server sqlconnection

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