小编Bil*_*mpf的帖子

从具有JSON主体的Fiddler调用时,POST Web API 4方法的参数为null

我有一个非常简单的Web API 4控制器,而不是一些遗留数据库代码.像这样的实体:

public class Employee
{
    public string EmploymentStatus { get; set; }
    public string CompanyCode { get; set; }
    public string Division { get; set; }
    public string OrgLevel1Code { get; set; }
    public string OrgLevel2Code { get; set; }
    public string OrgLevel3 { get; set; }
    public string StoreName { get; set; }
    public string EmployeeNumber { get; set; }
    public string EmployeeFirstName { get; set; }
    public string EmployeeMiddleInitial { get; set; }
    public string EmployeeLastName …
Run Code Online (Sandbox Code Playgroud)

json fiddler c#-5.0 asp.net-mvc-4 asp.net-web-api

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

从同一服务器上的MVC调用WCF服务时出现SocketException

我有一台带有IIS 7.5和一个IP的Windows 2008 Server.根,/ web和/ service下有两个Application./ web是一个MVC4应用程序,/ service是一个WCF 4.0服务.

当我从MVC使用服务时,我使用以下代码:

// Create the web request  
HttpWebRequest request = WebRequest.Create(TripServiceUrl + id) as HttpWebRequest;

// Get response  
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
    // Get the response stream  
    StreamReader reader = new StreamReader(response.GetResponseStream());

    // Console application output  
    tripJson = reader.ReadToEnd();
} 
Run Code Online (Sandbox Code Playgroud)

我得到以下SocketException:

[SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc wcf iis-7.5 asp.net-mvc-4

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

使用序号位置引用LinqToExcel中的列

我处于不寻常的位置,有两个不同的Excel上传模板,一个是"人性化的",一个是机器生成的.因此,列数据头是不同的,并且难以对齐它们.

因此,我想使用序数位置而不是列的"名称"来引用列映射.目前我有这个:

var excel = new ExcelQueryFactory(excelFileName);
excel.AddMapping<Student>(x => x.FirstName, "First Name");
excel.AddMapping<Student>(x => x.LastName, "Last Name");
excel.AddMapping<Student>(x => x.LastFour, "Last 4 Student ID");
excel.AddMapping<Student>(x => x.LastDate, "Last Date");
Run Code Online (Sandbox Code Playgroud)

我想做这样的事情:

var excel = new ExcelQueryFactory(excelFileName);
excel.AddMapping<Student>(x => x.FirstName, "A");
excel.AddMapping<Student>(x => x.LastName, "C");
excel.AddMapping<Student>(x => x.LastFour, "G");
excel.AddMapping<Student>(x => x.LastDate, "H");
Run Code Online (Sandbox Code Playgroud)

其中字母是Excel中的列引用.

有没有办法做到这一点?

c# asp.net excel linq-to-excel

7
推荐指数
2
解决办法
4793
查看次数

nmap忽略--script参数

我在Ubuntu 12.04服务器上安装了nmap 6.25,并尝试使用redis-info脚本.我已经下载了脚本并将其放在我的主目录中.当我跑:

nmap -p 6379 -Pn my.ip.num.ber --script redis-info.nse
Run Code Online (Sandbox Code Playgroud)

它只进行正常扫描,甚至根本不检查脚本.

Host is up.
PORT     STATE    SERVICE
6379/tcp filtered unknown
Run Code Online (Sandbox Code Playgroud)

而已.这是一个全新的安装,除了下载脚本之外,我什么都没做.我错过了什么?

ubuntu nmap redis

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

WCF REST服务不会返回实体的子项

我已经使用REST模板编写了一个WCF服务,该模板将defaultOutgoingResponseFormat设置为Json.在此之下,我使用Entity Framework和ObjectContext构建了一个简单的实体模型,以传递自定义POCO实体.

如果我传递单个实体,则系统按预期工作.如果我将子项添加到实体,则REST响应为空.在调试器中,实体填充正确,但服务本身根本不返回任何内容.

所以,例如,我有一个Trip.Get()方法.WCF代码如下所示:

[WebGet(UriTemplate = "{id}", ResponseFormat = WebMessageFormat.Json)]
public Model.Trip Get(string id)
{
    Model.Trip fetchedTrip = null;
    try
    {
        fetchedTrip = Library.Trip.Get(new Guid(id));
    }
    catch (Exception ex)
    {
        Debug.Write(ex.Message);
    }
    return fetchedTrip;
}
Run Code Online (Sandbox Code Playgroud)

Library.Trip.Get在工作版本中看起来像这样:

public static Model.Trip Get(Guid tripId)
{
    using (Model.POCOTripContext context = new Model.POCOTripContext())
    {
        var tripEntity = context.Trips.FirstOrDefault(c => c.Id == tripId) ?? new Model.Trip();
        return tripEntity;
    }
}
Run Code Online (Sandbox Code Playgroud)

这将返回预期结果,如下所示:

{ "ArrivalDate": "/日期(1334203200000-0400)/", "DepartureDate": "/日期(1334721600000-0400)/", "ID": "d6413d96-fe1f-4b1c-ae7a-3bbf516cdc2f", "姓名" :"测试123","照片":null,"PlacesOfInterest":null,"WhereTo":"Orlando,FL"}

但是,如果我将库方法更改为添加到子项中,则REST服务将返回空值.没什么,虚无...

public static Model.Trip Get(Guid tripId) …
Run Code Online (Sandbox Code Playgroud)

rest wcf json entity-framework poco

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

防止边缘穿过pygraphviz中的节点

我正在阅读一个JSON文件并使用pygraphviz动态创建一个图形,使用一个简单的循环:

hostdata = []
nodes = []
edges = {}
current_host = ""
trial = pgv.AGraph(strict=False, overlap=False)
for filename in os.listdir(options.directory):
    with open(options.directory + "/" + filename, "r") as myfile:
        hostdata = Truth(myfile.read().replace('\n', ''))
    nodes.append(hostdata.host["something"])
    current_something = hostdata.host["something"]
    for key, value in hostdata.peer.iteritems():
        nodes.append(key)
        edges[current_something] = key
        trial.add_edge(current_host, key)
Run Code Online (Sandbox Code Playgroud)

图表很复杂,但我真的更喜欢边缘不跨越节点.我试过,当我设置严格和重叠时,但我仍然有越过节点的线.

带有交叉节点的图形

这似乎是人们会碰到的东西,但我找不到任何东西.我可能做了一些完全错误的事情,或使用了错误的搜索词.任何帮助赞赏.

python pygraphviz

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