
所以我有一个由n个点组成的任意线(见图1所示的例子)
我想围绕这条线绘制一个轮廓(见图2),所以我需要计算周围多边形的点.
我开始在线上进行扩张,但这不起作用 - 见图3
有关如何做到这一点的任何建议?
我怀疑计算每个线段的法线是否用于翻译下面的新线和在当前位置上方的新线,然后将每个新线延伸到无穷大并将点定义为交叉点?
我正在尝试使用 AAD 帐户连接到 Azure SQL DB 作为 Azure 管道的一部分。大致我有以下几点:
具有关联服务连接的 Azure 管道。将 AAD 管理员设置为服务主体(连接的)的 Azure SQL DB。获取服务主体的不记名令牌的 Azure CLI 任务。
然后我有一个 Azure Powershell 脚本,它使用不记名令牌连接到数据库:
$conn = new-object System.Data.SqlClient.SqlConnection
$conn.ConnectionString = "Server=tcp:$($sqlServer),1433;Initial Catalog=$($sqlDB);Persist Security Info=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
$conn.AccessToken = $env:ACCESSTOKEN
$conn.Open()
Run Code Online (Sandbox Code Playgroud)
这会导致以下错误:
Login failed for user '<token-identified principal>
Run Code Online (Sandbox Code Playgroud)
允许运行管道的代理通过 SQL Server 防火墙。
在 DB 日志中,错误代码为 18456,状态为 132(AAD 失败)。
我已经使用 Azure CLI 使用服务连接服务主体登录、请求不记名令牌然后连接到数据库(使用上面的代码)手动测试了这一点,这是有效的。
如果我比较 Pipeline 测试和 Azure CLi 手动测试的不记名令牌,它们是相同的(除了 exp、uti 和 aio)
有任何想法吗?
我有一个控制器有两个动作:
[AcceptVerbs("GET")]
public ActionResult Add()
{
PrepareViewDataForAddAction();
return View();
}
[AcceptVerbs("POST")]
public ActionResult Add([GigBinderAttribute]Gig gig, FormCollection formCollection)
{
if (ViewData.ModelState.IsValid)
{
GigManager.Save(gig);
return RedirectToAction("Index", gig.ID);
}
PrepareViewDataForAddAction();
return View(gig);
}
Run Code Online (Sandbox Code Playgroud)
如您所见,当表单发布其数据时,Add操作使用GigBinder(IModelBinder的实现)
在这个活页夹我有:
if (int.TryParse(bindingContext.HttpContext.Request.Form["StartDate.Hour"], out hour))
{
gig.StartDate.Hour = hour;
}
else
{
bindingContext.ModelState.AddModelError("Doors", "You need to tell us when the doors open");
}
Run Code Online (Sandbox Code Playgroud)
表单包含一个ID为"StartDate.Hour"的文本框.
如上所示,GigBinder测试用户是否在文本框中输入了一个整数,其中包含id"StartDate.Hour".如果没有,则使用AddModelError将模型错误添加到模型状态.
由于gigs属性gigs.StartDate.Hour是强类型的,因此如果用户在表单文本框中键入了这个值,我就无法将其值设置为"TEST".
因此,我无法设置gigs.StartDate.Hour的值,因为用户输入的是字符串而不是整数.
由于Add Action返回视图并传递模型(返回View(gig);)如果modelstate无效,当表单重新显示验证消息时,值"TEST"不会显示在文本框中.相反,它将是gig.StartDate.Hour的默认值.
我如何解决这个问题?我真的卡住了!
我有一个表格需要填充2个模型.通常我在表单post post上使用ModelBinderAttribute,即
[Authorize]
[AcceptVerbs("POST")]
public ActionResult Add([GigBinderAttribute]Gig gig, FormCollection formCollection)
{
///Do stuff
}
Run Code Online (Sandbox Code Playgroud)
在我的表单中,字段的名称与模型属性相同...
但是在这种情况下,我有2个不同的模型需要填充.
我该怎么做呢?有任何想法吗?可能吗?
所以...我正在尝试使用RawCap捕获到localhost的流量当我运行rawcap时,它会在cmd提示符中报告数据包 - 但转储文件始终为空.
任何想法(我尝试使用admin privs运行)
想象一下,我有一个实现名为ISummary的接口的对象列表.此列表中的对象可能具有其他属性,即.
public interface ISummary {
Guid Id {get;set;}
string Title {get;set;}
DateTime Created {get;set;}
}
public class GigSummary: ISummary {
Guid Id {get;set;}
string Title {get;set;}
DateTime Created {get;set;}
string VenueName {get;set}
string Band {get;set;}
}
public class NewsSummary: ISummary {
Guid Id {get;set;}
string Title {get;set;}
DateTime Created {get;set;}
string Author{get;set}
}
Run Code Online (Sandbox Code Playgroud)
我现在将这个Gigs和News Summary对象列表(作为一个ISummary列表)作为模型传递给视图.
我想使用列表中包含的每种类型的不同部分来呈现此列表.
我怎么能这样做ASP.NET MVC?
我有一个Extension方法,它应该根据Ids的集合过滤一个Queryable对象(IQueryable)....
请注意,IQueryable是通过LinqToSql请求从我的数据库中获取的
public static IQueryable<NewsItemSummary> WithID(this IQueryable<NewsItemSummary> qry, IQueryable<Guid> Ids)
{
return from newsItemSummary in qry
where Ids.Contains(newsItemSummary.ID)
select newsItemSummary;
}
Run Code Online (Sandbox Code Playgroud)
如果从数组或列表创建ID并将其作为可查询列表传入,则它无法正常工作
例如...
GetNewsItemSummary().WithID(ids.AsQueryable<Guid>())
Run Code Online (Sandbox Code Playgroud)
如果Ids是由LinqToSql请求组成的,它就可以工作了!
这是已知问题:http: //connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?反馈ID = 355026
我的Ids集合不能来自LinqToSql请求......
注意,如果我更改函数使它消耗和IList而不是IQueryable ....
public static IQueryable<NewsItemSummary> WithID(this IQueryable<NewsItemSummary> qry, IList<Guid> Ids)
{
return from newsItemSummary in qry
where Ids.Contains(newsItemSummary.ID)
select newsItemSummary;
}
Run Code Online (Sandbox Code Playgroud)
我现在得到以下异常:
Method 'Boolean Contains(System.Guid)' has no supported translation to SQL.
Run Code Online (Sandbox Code Playgroud)
所以......我想做的就是根据Guids列表或数组过滤我的新闻集合.
我试图使用spring.net和nihibernate作为我的数据层.
我有一个简单的DAO对象,其中包含以下代码:
[Transaction]
public long Save(Request entity)
{
return (long)CurrentSession.Save(entity);
}
Run Code Online (Sandbox Code Playgroud)
每当调用此代码时,我都会收到以下错误:
"没有Hibernate Session绑定到线程,配置不允许在这里创建非事务性的"
我的DAO层具有以下配置,在我的web.config中引用:
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net"
xmlns:tx="http://www.springframework.net/tx"
xmlns:db="http://www.springframework.net/database"
xmlns:aop="http://www.springframework.net/aop"
>
<!-- Referenced by main application context configuration file -->
<description>
The Northwind object definitions for the Data Access Objects.
</description>
<!-- Property placeholder configurer for database settings -->
<object type="Spring.Objects.Factory.Config.PropertyPlaceholderConfigurer, Spring.Core">
<property name="ConfigSections" value="databaseSettings"/>
</object>
<!-- Database and NHibernate Configuration -->
<db:provider id="DbProvider"
provider="SqlServer-2.0"
connectionString="Data Source=ME-LT;Initial Catalog=SupplyAndDemand;Integrated Security=True"/>
<object id="NHibernateSessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate21">
<property name="DbProvider" ref="DbProvider"/> …Run Code Online (Sandbox Code Playgroud) 我有以下路线
routes.MapRoute(
"GigDayListings", // Route name
"gig/list/{year}/{month}/{day}", // URL with parameters
new { controller = "Gig", action = "List" },
new
{
year = @"^[0-9]+$",
month = @"^[0-9]+$",
day = @"^[0-9]+$"
} // Parameter defaults
);
Run Code Online (Sandbox Code Playgroud)
当我访问URL时
gig/list/2009/01/01
Run Code Online (Sandbox Code Playgroud)
这条路线完美匹配,我的行动被召唤.
在我看来,我有一个帮助器,它执行以下操作:
var urlHelper = new UrlHelper(ViewContext);
string url = urlHelper.RouteUrl(ViewContext.RouteData.Values);
Run Code Online (Sandbox Code Playgroud)
生成的字符串是:
http://localhost:3539/gig/list?year=2005&month=01&day=01
Run Code Online (Sandbox Code Playgroud)
为什么不呢
http://localhost:3539/gig/list/2005/01/01
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我有一个网页,其中包含一个名为"myVariable"的JavaScript变量.
在此网页中是一个指向第二个网页的iframe.
两个页面都在同一个域中.
iframe中的页面需要访问父网页中定义的"myVariable".
我使用以下代码使用Firefox成功访问了此变量:
document.defaultView.parent.myVariable
Run Code Online (Sandbox Code Playgroud)
但是,这在Internet Explorer中不起作用.....
我如何在Internet Explorer中执行此操作?
所以,我有一个页脚,它将出现在我的Web应用程序的每个页面上
我需要它来渲染动态数据......这意味着每个控制器动作都需要返回包含这些数据的viewData ..以及特定于动作的数据
你们怎么实现这个?或许基本控制器的构造函数?
byte[] header = new byte[]{255, 216};
string ascii = Encoding.ASCII.GetString(header);
Run Code Online (Sandbox Code Playgroud)
我希望ASCII等于FFD8(JPEG SOI标记)
相反,我得到"????"
我有一个函数将文件提取到字节数组(数据).
int contentLength = postedFile.ContentLength;
byte[] data = new byte[contentLength];
postedFile.InputStream.Read(data, 0, contentLength);
Run Code Online (Sandbox Code Playgroud)
后来我使用这个字节数组来构造一个System.Drawing.Image对象(其中data是字节数组)
MemoryStream ms = new MemoryStream(data);
Image bitmap = Image.FromStream(ms);
Run Code Online (Sandbox Code Playgroud)
我得到以下异常"ArgumentException:参数无效."
原始发布的文件包含500k jpeg图像...
任何想法为什么这不起作用?
注意:我向你保证我有一个有效的理由转换为字节数组然后转换为内存流!!
asp.net-mvc ×5
c# ×2
arrays ×1
ascii ×1
azure ×1
azure-devops ×1
byte ×1
contains ×1
encoding ×1
firefox ×1
forms ×1
geometry ×1
iframe ×1
image ×1
linq ×1
linq-to-sql ×1
math ×1
nhibernate ×1
outline ×1
pcap ×1
repopulation ×1
session ×1
spring.net ×1
stream ×1
urlhelper ×1
vector ×1
viewdata ×1