你如何检查我使用的是打开还是关闭
if (SQLOperator.SQLCONNECTION.State.Equals("Open"))
Run Code Online (Sandbox Code Playgroud)
然而,即使是国家"开放",它也没有通过这项检查.
我正在尝试将参数添加到与signalr的连接中.
我正在使用Builder来创建我的客户端连接并启动它:
var connection = new HubConnectionBuilder()
.WithUrl("http://10.0.2.162:5002/connection")
.WithConsoleLogger()
.WithMessagePackProtocol()
.WithTransport(TransportType.WebSockets)
.Build();
await connection.StartAsync();
Run Code Online (Sandbox Code Playgroud)
我想在这个连接中发送一个简单的参数:类似于:
"令牌":"123"
在我的服务器端,我想我可以从HttpContext中获取此参数:
public override Task OnConnectedAsync()
{
var httpContext = Context.Connection.GetHttpContext();
var token = httpContext.Request.Query["Token"];
return base.OnConnectedAsync();
}
Run Code Online (Sandbox Code Playgroud)
知道怎么发送这个参数吗?谢谢.
我正在查看文档WebAPI 2
,我对动作结果的构建方式感到非常失望.我真的希望有更好的方法.
所以文档说我可以返回这些:
**void** Return empty 204 (No Content)
**HttpResponseMessage** Convert directly to an HTTP response message.
**IHttpActionResult** Call ExecuteAsync to create an HttpResponseMessage, then convert to an HTTP response message.
**Other type** Write the serialized return value into the response body; return 200 (OK).
Run Code Online (Sandbox Code Playgroud)
我没有看到一个干净的方法来返回具有自定义HTTP状态代码,自定义标头和自动协商内容的项目数组.
我希望看到的是类似的东西
public HttpResult<Item> Post()
{
var item = new Item();
var result = new HttpResult<Item>(item, HttpStatusCode.Created);
result.Headers.Add("header", "header value");
return result;
}
Run Code Online (Sandbox Code Playgroud)
这样我就可以浏览一个方法并立即看到返回的内容,并修改状态代码和标题.
我发现最接近的是NegotiatedContentResult<T>
,带有奇怪的签名(为什么它需要一个控制器实例?),但是没有办法设置自定义头文件?
有没有更好的办法 ?
我正在尝试为平静的页面制作过滤器.
我有一个名为Companies的页面,还有一个用于打开另一个页面的按钮,CompanyUsers,来自该公司的用户.
它已经打开了新页面,但它给了我所有用户,我想按照我点击的行进行过滤.
我尝试更改CompanyUsers的Controller添加参数,但在此之后我不知道如何在CompanyUsers中设置过滤器.
我的Onclick在CompaniesGrid.ts
protected onClick(e: JQueryEventObject, row: number, cell: number): void {
super.onClick(e, row, cell);
let item = this.itemAt(row);
if ($(e.target).hasClass('usuario-row')) {
window.location.href = '/Cadastros/EmpresasUsuarios?empresaId=' + item.EmpresaId;
}
}
Run Code Online (Sandbox Code Playgroud)
我怎么能平静地做到这一点?有一个简单的方法吗?
谢谢!!
我正在尝试在NuGet的PCL iOS项目中安装Xamarin.Mobile,我得到了这个错误!
无法安装软件包'xamstore-xamarin.mobile 0.7.1'.您正在尝试将此软件包安装到以"Xamarin.iOS,Version = v1.0"为目标的项目中,但该软件包不包含与该框架兼容的任何程序集引用或内容文件.有关更多信息,请与软件包作者联系.
这是我的AppDelegate
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make …
Run Code Online (Sandbox Code Playgroud) 我正在使用Nestable List进行相关访问,当我将项目从List1放到List2时我必须保存在数据库上,那么我如何识别哪些项目在List2上被删除?
这是我的代码:
<div class="col-lg-6">
<h3 class="droppTextCenter">Serviços Disponíveis</h3>
<div class="dd" id="nestable">
<script id="template" type="text/template7">
<ol class="dd-list">
{{#each Services}}
<li class="dd-item" data-id="{{Id}}">
<div class="dd-handle">
<div class="col-lg-9">
{{Descryption}}
</div>
</div>
</li>
{{/each}}
</ol>
</script>
</div>
</div>
<div class="col-lg-6">
<h3 class="droppTextCenter">Serviços Liberados para o Usuário</h3>
<div class="dd" id="nestable2">
<script id="template2" type="text/template7">
<ol class="dd-list">
{{#each ServicesReleased}}
<li class="dd-item" data-id="{{Id}}">
<div class="dd-handle">
<div class="col-lg-9">
{{Descryption}}
</div>
</div>
</li>
{{/each}}
</ol>
</script>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
我正在使用template7来制作List.
所以我将在nestable onChange上创建一个ajax方法,将其保存在数据库中.
$('#nestable').nestable({
maxDepth: 1,
group: 1
}).on('change', updateOutput);
// activate …
Run Code Online (Sandbox Code Playgroud) 我必须做一个搜索来返回一个值,我要做的是两个字段相乘的总和.我有以下代码:
internal double TotalRes(long Id)
{
double total = 0;
Reserve rAlias = null;
var query = Session.QueryOver<Item>();
query = query.JoinAlias(e => e.Reserve, () => rAlias);
query = query.Where(() => rAlias.Id == Id);
query = query.Select(Projections.Sum<Item>(acct => acct.Ammount * acct.Wight));
object result = query.UnderlyingCriteria.UniqueResult();
if (result != null)
total = Convert.ToDouble(result);
return total;
}
Run Code Online (Sandbox Code Playgroud)
它给出以下错误:
变量'acct'类型'tem'在范围''中引用,但未设置
我怎样才能归还这个值?
我正在制作一个实现从相机拍照并从库中选择照片.
使用ELCImagePickerController从库中拍摄照片并在scrollview中设置图像.
我想要做的是从相机拍摄几张图像并在同一滚动视图上设置它.
目前我的实施是:
- (IBAction)takePhoto:(UIButton *)sender {
UIImagePickerController *cameraPicker = [[UIImagePickerController alloc] init];
cameraPicker.delegate = self;
cameraPicker.allowsEditing = YES;
cameraPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:cameraPicker animated:YES completion:NULL];
}
- (void)imagePickerController:(UIImagePickerController *)photoPicker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[photoPicker dismissViewControllerAnimated:YES completion:NULL];
UIImage *image=[info objectForKey:UIImagePickerControllerEditedImage];
UIImageView *imageview = [[UIImageView alloc] initWithImage:image];
[imageview setContentMode:UIViewContentModeScaleAspectFit];
[self.scrollView addSubview:imageview];
[self dismissModalViewControllerAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)
有了这个,我每次只能拍一张照片,当我再次设置它时,它会替换另一张照片.我该怎么办?以及我如何做到这一点?
我在C#/ Xamarin中制作混合应用程序,我想为所有应用程序(iOS,Android,Windows Phone)制作自定义菜单.
所以,我创建了一个MasterPage
作为我的菜单.
public MasterPage()
{
InitializeComponent();
var masterPageItems = new List<MenuItem>();
masterPageItems.Add(new MenuItem
{
Title = "Administração",
});
masterPageItems.Add(new MenuItem
{
Title = "Meus Dados",
IconSource = "contacts.png",
TargetType = typeof(MeusDados),
});
masterPageItems.Add(new MenuItem
{
Title = "Dados Cadastrais",
IconSource = "contacts.png",
TargetType = typeof(MeusNegocios),
});
var listView = new ListView
{
ItemsSource = masterPageItems,
ItemTemplate = new DataTemplate(() =>
{
var imageCell = new ImageCell();
imageCell.SetBinding(TextCell.TextProperty, "Title");
imageCell.SetBinding(ImageCell.ImageSourceProperty, "IconSource");
return imageCell;
}),
VerticalOptions = LayoutOptions.FillAndExpand, …
Run Code Online (Sandbox Code Playgroud) 我正在制作一个从 Firebird 到 SQL Server 的同步应用程序。\n并且我正在使用 Dapper Plus 的 BulkInsert。
\n\nvar fbClient = new FirebirdConnect();\nusing (var source = fbClient.GetConnection())\n{\n\n if (source.State == ConnectionState.Closed)\n source.Open();\n\n var sqlClient = new AzureConnect();\n using (var target = sqlClient.GetConnection())\n {\n if (target.State == ConnectionState.Closed)\n target.Open();\n\n var lastUpdate = connection.Query<DateTime>($"select coalesce((select max(DateSyncTarget) from {metadados.TargetName}), getdate()-10000) LastUpdate").ToList();\n\n var resultSource = source.Query<MyClass>("select * from MyClass");\n\n target.BulkInsert(resultSource.Where(w => w.Data > lastUpdate[0]));\n\n var resultTargert = target.Query<MyClassSource>("select * from MyClass")\n\n source.BulkInsert(resultTargert.Where(w => w.Data > lastUpdate[0]));//Error here\n\n }\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n当我查阅源代码以在目标中进行插入时,一切都发生得很好。
\n\n …如何从中重定向到另一个页面 Application_Error
?
目前我正在做
Response.Redirect("~/Account/LogOn");
Run Code Online (Sandbox Code Playgroud)
但我想做点什么 RedirectToAction()
我正在使用石英 2.5.0.0
我有以下代码来运行我想要的任何工作。我所有的工作都放在一个文件夹中,因为我只是把它放在那里。
var scheduler = StdSchedulerFactory.GetDefaultScheduler();
scheduler.Start();
var t = new ImportingLib.Importer();
t.DoImport();
foreach (var component in t.CallAllComponents())
{
var job = JobBuilder.Create(component)
.WithIdentity(component.Name)
.Build();
var trigger = TriggerBuilder.Create()
.WithIdentity($"{component.Name}Trigger")
.StartNow()
.WithSimpleSchedule(x => x
.WithIntervalInSeconds(10)
.RepeatForever())
.ForJob(component.Name)
.Build();
scheduler.ScheduleJob(job, trigger);
}
Run Code Online (Sandbox Code Playgroud)
我想让这个工作每 10 秒运行一次,但我必须等待它自己结束,在此之后,再次启动同一个工作。一种知道胎面何时结束应该如何工作的方法,但我没有找到如何做到这一点。知道如何让它工作吗?
我正在与Facebook和Google进行集成,以便在我的应用程序中使用此应用程序,但是当我点击按钮以便通过Facebook或Google登录时,我得到了302响应,这就是对Fiddler的响应.
它通过命中ExternalLogin重定向到登录.
这是我的Startup.cs
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddFacebook(fOptions => {
fOptions.AppId = "myAppId";
fOptions.AppSecret = "myAppSecret";
fOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; })
.AddGoogle(gOptions => {
gOptions.ClientId = "myClintId";
gOptions.ClientSecret = "myClientSecret;
gOptions.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; })
.AddCookie();
Run Code Online (Sandbox Code Playgroud)
我也在使用Identity来创建用户.
我在AccountController上的ExternalLogin:
public IActionResult ExternalLogin(string provider, string returnUrl)
{
var props = new AuthenticationProperties()
{
RedirectUri = Url.Action("ExternalLoginCallback"),
Items =
{
{ "returnUrl", returnUrl },
{ "scheme", provider },
}
};
return Challenge(props, provider);
}
Run Code Online (Sandbox Code Playgroud)
我的按钮用相应的外部登录:
<div class="col_full text-center nomargin" style="margin-bottom: 5px !important">
<a asp-action="ExternalLogin" asp-route-provider="Facebook" asp-route-returnUrl="@ViewData["ReturnUrl"]" …
Run Code Online (Sandbox Code Playgroud) c# ×11
ios ×3
ado.net ×1
android ×1
asp.net-mvc ×1
camera ×1
dapper-plus ×1
firebird ×1
google-login ×1
identity ×1
ios-camera ×1
javascript ×1
jquery ×1
objective-c ×1
quartz.net ×1
queryover ×1
signalr-hub ×1
typescript ×1
xamarin ×1
xamarin.ios ×1