我在我的打字稿中有下面的代码来调用web api方法并检索一个PDF的二进制字节数组(blob).我的用户要求是在新窗口中打开PDF.
$scope.selectRow = (itemImageNumber: string, printProcessId: string, printXmlId: string) => {
itemService.GetOutgoingDocument($scope.item.ItemId, itemImageNumber, printProcessId, printXmlId).success((response) => {
var file = new Blob([response], { type: 'application/pdf' });
var fileUrl = URL.createObjectURL(file);
//$scope.outDocContent = $sce.trustAsResourceUrl(fileUrl);
var win = window.open($sce.trustAsResourceUrl(fileUrl));
win.focus();
}).error(() => {
var message =
"The document you selected can’t be displayed at this time. Please call Customer Service at xxx-xxx-xxxx for assistance.";
$rootScope.$broadcast("app-message", {
type : "danger",
message : message
});
});
}
Run Code Online (Sandbox Code Playgroud)
此代码在Chrome中运行良好.该文件按预期打开.然而,IE问"你想让这个网站在你的电脑上打开一个应用程序吗?" 如果允许,请告诉我"没有安装应用程序来打开这种链接(blob)".
有关如何在新选项卡中打开它或将blob保存为文件作为最后手段的任何想法?
我有一台装有VS 2012的VS和VS2010的机器.我正在尝试按照http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api上的代码来试用Web API .我尝试在网上关注如何解决问题的一些不同的链接,但仍然无法使用IIS Express/Cassini为我的Windows 7 x64机箱上的主机使用Web API.目前我得到"未找到方法:'Void Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(Boolean)'." 尝试查看应该是什么产品列表时出错.
我完全按照写入的方式跟踪网页,并且没有手动添加任何内容.我确实为网络堆栈设置了夜间存储库http://www.myget.org/F/aspnetwebstacknightly/,但不知道是否会导致问题.如果有帮助的话,这是NuGet的Get-Package转储程序.
PM> Get-Package
Id Version Description/Release Notes
-- ------- -------------------------
EntityFramework 5.0.0-rc Entity Framework is Microsoft's recommended data access technology for new applications.
jQuery 1.6.2 jQuery is a new kind of JavaScript Library....
jQuery.UI.Combined 1.8.11 jQuery UI is an open source library of interface components — interactions, full-featured widgets, and animation effects — based on the stellar jQuery javascript library . Each component is built accordin... …Run Code Online (Sandbox Code Playgroud) 我正在使用 PyCharm 3.4.1 并从 Mongo 大学学习 MongoDB。在代码中,他们让我们使用 Python 使用带有 Bottle 的 MVC 模式创建 html 页面。
当我将 .tpl 类型的文件添加到 PyCharm 中的编辑器时,代码中没有“智能感知”或对模型的支持。将其更改为 html 文件类型列表会有所帮助,但编辑器中不支持 Python。
是否有插件或其他一些更改可以更好地支持编辑?似乎有人在今年早些时候在如何在 pycharm 中突出显示 tpl 文件中提出了类似的问题?
好的,我有一个托管在中央标准时区的Web服务器.IIS服务器配置为时区,因此每当在服务器上使用DateTime.Now或创建类型为Local的新DateTime时,它都处于中央时间.
问题是该网站是(国际)国内申请,我可以在美国或加拿大的任何地方拥有客户.该网站拥有的一个东西是用于安排约会的"调度程序".我们决定易于开发,以UTC格式将所有DateTime值存储在数据库中,并且所有流入和流出API的流量也都是UTC.问题是当我在服务器端创建日期/时间值时,我经常遇到问题.
比方说,我需要以编程方式为服务器上太平洋标准时区的客户端创建约会,时间为上午8点.在过去,我做过这样的事情:
var appointment = new new DateTime(2015, 04, 17, 08, 00, 00, DateTimeKind.Unspecified)
var utcAppointment = TimeZoneInfo.ConvertTimeToUtc(appointment,
TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"))
Run Code Online (Sandbox Code Playgroud)
我在我的程序中做了很多其他的日期/时间操作,我想要去Nodatime而不是.我知道我可以很容易地从Nodatime变量中获取UTC DateTime.我感到困惑的是如何在特定日期/时间为特定时区创建Nodatime变量?我看到的所有例子都与模式和阅读字符串或创建一个基本上是"现在"的Instant有关.我想做一些事情,比如使用现有的BCL DateTime对象,无论"Kind"如何,并将其转换为具有我设置的特定时区的Nodatime对象.
我认为Nodatime是一个很棒的图书馆,但阅读用户指南只会让我对转换进出BCL感到头疼.
我有一个网页,其中包含一个iFrame,其中的HTML定义如下所示:
<iframe id="page_is_fresh" src="~/HTML/fresh.html" style="display: none"></iframe>
Run Code Online (Sandbox Code Playgroud)
我的网站在/ Marketing子文件夹下运行,因此所有网址都类似于http://myserver/Marketing/SomeFolder/someitem.html
当表单上的项目发生更改时,我可以使用JavaScript来更改iframe的src。
$('#page_is_fresh').attr('src', '/HTML/stale.html');
Run Code Online (Sandbox Code Playgroud)
问题是,这使得URL http://myserver/HTML/stale.html
我尝试使用“〜/ HTML / stale.html”,这给了我http://myserver/Marketing/SomeFolder/~/HTML/stale.html也不起作用。
如何获得给我http://myserver/Marketing/HTML/stale.html的信息而不必对/ Marketing部分进行硬编码?
我在 VSCode 中创建了两个不同的 Node.JS 项目。有时,项目 A 需要调用项目 B。项目 A 正在端口 60100 上运行。项目 B 正在端口 60200 上运行。当我尝试使用 http://localhost:60200/ 调用项目 B 时,我得到一个传输错误。如果我在两个容器配置 (devcontainer.json) 上公开端口 60200,它将引发错误,因为该端口已在使用中。
我知道我可以使用 docker-compose 并在同一个项目中运行它们,但它们有单独的 git home 并且大多数时候都是独立的。
我能做些什么来让它们连接起来吗?也许对每个单独的容器使用 docker-compose,但在组合中使用相同的网络名称?这能让他们交流吗?
我即将疯狂处理日期时间问题和网络.
我在中央时区托管了一个Web服务器.当东部时区的客户使用我的应用程序尝试和安排某一天的项目时,他们会传递(例如)2015年3月14日的值.当我们将代码传递回我们发送到web api的模型时,我们坚持使用类似下面的代码.
moment.utc($("#mydatepicker").val).hour(0).minute(0).second(0)).toISOString();
Run Code Online (Sandbox Code Playgroud)
这会产生如下字符串:
2015-03-14T04:00:00.000Z
Run Code Online (Sandbox Code Playgroud)
在web api中将项目转换回服务器时,它将转换为
3/13/2015 11:00:00 PM
Run Code Online (Sandbox Code Playgroud)
逻辑然后剥离时间,你可以看到从这里发生的事情.由于我剥离了时间,现在是前一天,这是持久存储到数据库的值.
我需要知道从某个时刻发送值的一些方法,最好是作为客户端时区的ZonedDateTime进入web api.然后,我可以将其转换为UTC以保持数据库中的持久性.
我已经看到了使用NodaTime.Serialization.JsonNet的事情,但我不清楚如何将它与Moment一起使用并在web api/ajax中来回传递.
我已成功在我的Web API应用程序上实现了Swashbuckle/Swagger,但对输出不满意.
我的一个web api方法(企业事件记录工具)接受Complex对象值的JSON对象.
问题是当存在可以使用的可接受值的选定列表时,参数被列为字符串对象.我已设置默认值,以便在发送不正确的内容时,我设置为默认值.
我想我可以添加其他返回可接受值的服务调用,但我宁愿不这样做.
我确实在Swashbuckle上实现了模式部分来设置一个有效的"示例"对象,但它只列出了一百种不同的组合.
我能给出的最好的例子如下:
EnterpriseEvent {
EventType (string, optional),
SourceSystem (string, optional),
Company (string, optional),
Interface (string, optional),
TransactionType (string, optional),
EventDateTime (string, optional),
EventXML (Array[Object], optional),
Operation (string, optional),
LoggingLevel (string, optional)
}
Run Code Online (Sandbox Code Playgroud)
SourceSystem的可接受值可能是"Accounting"或"Payments"或"Portal".公司的可接受值可以是"子公司1"或"合作伙伴1".
有什么东西我可以添加到Swashbuckle/Swagger来获取输出的某个地方吗?
我有一个类,它采用标准的地址属性并存储它们.State属性的类型为USStateCodesType.以下是用于存储属性的代码示例:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.225")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="http://SP/Items/Schemas")]
public partial class BusinessAddress
{
private string address1Field;
private string address2Field;
private string cityField;
private USStateCodesType stateField;
private bool stateFieldSpecified;
private string zipField;
/// <remarks/>
public string Address1
{
get
{
return this.address1Field;
}
set
{
this.address1Field = value;
}
}
Run Code Online (Sandbox Code Playgroud)
USStateCodesType包含带字符串键和值的私有字典.默认构造函数加载字典并由任何重载调用.国家只有一个公共财产.编码如下:
public string State
{
get
{
return iDict[_key];
}
set
{
if (iDict.ContainsValue(value))
{
foreach (string k in iDict.Keys)
if (iDict[k] == value)
_key = k;
}
else
_key = …Run Code Online (Sandbox Code Playgroud) 我有一个函数返回一个对象数组.问题是,对象可以是三种不同类型之一.我试图将这些对象分解为不同自定义类型的数组.
例如:
var collection = something.ReturnObjArray();
var Details = collection.Where(a => a is DetailItem);
var Addenda = collection.Where(a => a is AddendaItem);
Run Code Online (Sandbox Code Playgroud)
如果我执行上述操作并尝试访问foreach循环中的数据,以将附录放入详细项目中的集合中:
foreach (var addendaItem in Addenda)
{
var detailItem = Details.Single(d => d.DetailAddendaKey == addendaItem.Key);
detailItem.Addenda.Add(addendaItem);
}
Run Code Online (Sandbox Code Playgroud)
我得到的错误如下:
'object'不包含'DetailAddendaKey'的定义,并且没有扩展方法'DetailAddendaKey'可以找到接受'object'类型的第一个参数(你是否缺少using指令或汇编引用?)
其中包括.如果我尝试将详细信息和附录的var更改为:
IEnumerable<DetailItem> Details = collection.Where(a => a is DetailItem);
IEnumerable<AddendaItem> Addenda = collection.Where(a => a is AddendaItem);
Run Code Online (Sandbox Code Playgroud)
我超越了上面的错误,但现在得到:
无法隐式转换'System.Collections.Generic.IEnumerable<object>'为'System.Collections.Generic.IEnumerable<MyNameSpace.DetailItem>'.存在显式转换(您是否错过了演员?)
有什么想法我需要做什么?
c# ×4
javascript ×3
nodatime ×2
arrays ×1
asp.net ×1
bottle ×1
containers ×1
datetime ×1
docker ×1
html ×1
iframe ×1
jquery ×1
json ×1
linq ×1
networking ×1
pycharm ×1
python ×1
python-2.7 ×1
swagger-2.0 ×1
swagger-ui ×1
swashbuckle ×1
typescript ×1