有没有办法阻止SignalR服务器?我有自己托管的SignalR服务器作为Windows服务,但我找不到任何方法来停止服务器/服务.
我试过这个但它不起作用 - 服务器一直在监听并阻止服务停止.
或者,如何完全停止服务,强制SignalR关闭?
[编辑]:
大多数来源我不能分享(版权/安全)但我会尽我所能:
SignalR服务器初始化
Task signalRTask = null;
IDisposable SignalR;
#region SignalR server init
// Kreiraj SignalR server
try
{
cancelTokenSrc = new CancellationTokenSource();
signalRTask = Task.Factory.StartNew(RunSignalR, TaskCreationOptions.LongRunning, cancelTokenSrc.Token);
logfile.Info("Starting notifications pool thread...");
//Console.WriteLine(DateTime.Now.ToString("dd.MM.yyyy. HH:mm:ss ") + "Starting notifications pool thread...");
senderThread = new Thread(delegate()
{
sender.poolEvents();
});
senderThread.Start();
}
catch (Exception ex)
{
// greška u startanju SignalR servera
ServiceEngine.logfile.Info("Error starting SignalR on " + signalr_bind + " with error:" + ex.ToString());
//Console.WriteLine(DateTime.Now.ToString("dd.MM.yyyy. …Run Code Online (Sandbox Code Playgroud) 在处理单词模板时,需要在IF字段中放置重复块,类似于:
使用.DOC/.DOCX的WordTemplate示例代码:
{ IF {MERGEFIELD DataSource1.FieldName}=”123456” “IF SECTION
Then a repeat block here using a table row that is bookmarked:
------------------------------------------------------------
| «Datasource1.IdColHeader» | «Datasource1.NameColHeader» |
------------------------------------------------------------
|«RepeatingDatasource2.Id» | «RepeatingDatasource2.Name» |
------------------------------------------------------------
” “Else Section
Second set of repeat block with different datasource
-------------------------------------------------------
| Id | Name |
-------------------------------------------------------
|«RepeatingDatasource3.Id»|«RepeatingDatasource3.Name»|
-------------------------------------------------------
”}
Run Code Online (Sandbox Code Playgroud)
使用WordWriter的WordTemplate的C#示例代码:
private static void ProcessWordTemplate(WordTemplate docTemp)
{
try
{
docTemp.Process();
}
catch (Exception ex)
{
throw new ApplicationException(ex.Message);
}
}
Run Code Online (Sandbox Code Playgroud)
对于DOCX WordTemplate, …
通过ajax上传文件时遇到了一些麻烦。每当我尝试上载它时,都会在保存文件时添加额外的行,这些行会损坏文件。像这样
------WebKitFormBoundaryR4wrAzWF9BYdge12
Content-Disposition: form-data; name="files"; filename="testing - Copy.txt"
Content-Type: text/plain
this is a test
------WebKitFormBoundaryR4wrAzWF9BYdge12--
Run Code Online (Sandbox Code Playgroud)
这是我的HTML
var formData = new FormData();
formData.append("files", files[x], files[x].name);
var tempUrl = url + "&filename=" + files[x].name;
console.log(tempUrl, formData);
$.ajax({
url: tempUrl,
type: "Post",
data: formData,
processData: false,
contentType: false,//"multipart/form-data",
success: function () {
console.log("done!")
}});
Run Code Online (Sandbox Code Playgroud)
这是C#后端。我没有写这个,而且我对C#的使用也不是很熟练,所以如果我错过了一个简单的修复程序,对不起。
public void ProcessRequest(HttpContext context, string tenant, string userId, int parentId)
{
try
{
string filename = context.Request.QueryString["filename"];
bool complete = string.IsNullOrEmpty(context.Request.QueryString["Complete"]) ? true : bool.Parse(context.Request.QueryString["Complete"]);
bool getBytes = …Run Code Online (Sandbox Code Playgroud) 我正在使用Native GDI +捕获窗口"屏幕上".屏幕关闭时它不起作用(生成黑色图像).我该如何解决?(我正在使用.Net 4.5)
public static Image CaptureWindow(IntPtr handle)
{
IntPtr hdcSrc = User32.GetWindowDC(handle);
RECT windowRect = new RECT();
User32.GetWindowRect(handle, ref windowRect);
int width = windowRect.right - windowRect.left;
int height = windowRect.bottom - windowRect.top;
IntPtr hdcDest = Gdi32.CreateCompatibleDC(hdcSrc);
IntPtr hBitmap = Gdi32.CreateCompatibleBitmap(hdcSrc, width, height);
IntPtr hOld = Gdi32.SelectObject(hdcDest, hBitmap);
Gdi32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, SRCCOPY);
Gdi32.SelectObject(hdcDest, hOld);
Gdi32.DeleteDC(hdcDest);
User32.ReleaseDC(handle, hdcSrc);
Image image = Image.FromHbitmap(hBitmap);
Gdi32.DeleteObject(hBitmap);
return image;
}
Run Code Online (Sandbox Code Playgroud) 目前,我在App.xaml.cs类中使用此代码设置主工具栏背景颜色:
//SET PRIMARY TOOLBAR COLOR
Current.Resources = new ResourceDictionary ();
Color xamarin_color = Color.FromHex ("#3498db");
var navigationStyle = new Style (typeof (NavigationPage));
var barBackgroundColorSetter = new Setter { Property = NavigationPage.BarBackgroundColorProperty, Value = xamarin_color };
navigationStyle.Setters.Add (barBackgroundColorSetter);
Current.Resources.Add (navigationStyle);
Run Code Online (Sandbox Code Playgroud)
navigationPage PRIMARY工具栏正确更改其颜色.但SECONDARY工具栏不会更改其默认颜色(灰色),我找不到任何方法或属性来更改它.如何更改辅助工具栏的背景颜色?
有人知道如何轻松地重用 .Net Core 中的内置模型绑定器吗?
我必须定期调用一个返回 NamedValuePaired 数据(如查询字符串)的 api 有没有一种简单的方法来重用模型绑定器而不是解析数据?
我可以只获取数据并再次调用我自己的控制器来进行绑定,但是,除了向我自己的控制器发送 http 帖子之外,还必须有其他方法。
目前我正在做以下事情:
var rawResponse = "";
using (var client = new HttpClient())
{
//Post to paypal
var response = await client.PostAsync(_options.TokenUrl, new StringContent(parameters, Encoding.UTF8, "text/namevalue"));
//read response
rawResponse = await response.Content.ReadAsStringAsync();
}
var nameValues = QueryHelpers.ParseQuery(rawResponse);
Model m = new Model();
if (nameValues.ContainsKey("RESULT"))
m.Result = Convert.ToByte(nameValues["RESULT"].FirstOrDefault());
// etc....
Run Code Online (Sandbox Code Playgroud)
理想情况下,我想接收响应并将其传递给内置的模型绑定器,就像它被发布给我一样。
我有一个简单的控制台应用程序:有一个循环来处理来自外部源的数据。当我使用命令dotnet MyApp.dll在bash中运行它时,但是在启动超级用户时,在日志中出现错误:
Unhandled Exception: System.InvalidOperationException: Cannot read keys when either application does not have a console or when console input has been redirected. Try Console.Read.
at System.ConsolePal.ReadKey(Boolean intercept)
at Crawler.Test.Program.Main(String[] args)
Run Code Online (Sandbox Code Playgroud)
但是在主方法中,我没有调用“ Console.ReadKey”之类的东西。
我正在尝试执行类似守护程序的操作。
我的主管会议
[program:dotnetapp]
directory = /var/app/MyApp
command = /bin/bash -c "dotnet /var/app/MyApp/MyApp.dll"
numprocs = 1
autostart = true
autorestart = true
user=www-data
Run Code Online (Sandbox Code Playgroud)
主要
using (MyDisposableClass myClass = new MyDisposableClass())
{
myClass.Start();
Console.WriteLine("App started...");
}
Run Code Online (Sandbox Code Playgroud) 我正在 c# .Net 4.5.1 中开发 Windows 窗体应用程序,并且我添加了一些 rdlc 报告作为它的一部分。每个报告都是为不同的目的而添加的,并根据用户请求以单独的形式显示。每个表单都很简单,它只是调用适配器来填充数据集,然后刷新报告以显示它:
namespace TestReporting
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'CMSDataSet.BillingDoc' table. You can move, or remove it, as needed.
this.BillingDocTableAdapter.Fill(this.CMSDataSet.BillingDoc);
this.reportViewer1.RefreshReport();
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,当我打印报告或按打印布局时,报告在报告查看器的左上角显示很小,请参阅快照。在互联网上搜索了很多之后,我认为问题与我的Windows 10机器上默认设置为3840 X 2160的机器分辨率有关。我的机器字体的字体大小设置为350%,这是我的最大值喜欢 。我注意到,当我将机器字体大小减小到 100% 时,报告可以正常打印并且正在查看报告查看器的完整视图,但是人类无法读取此字体大小。有没有一种方法或代码可以让我忽略仅用于保存报表查看器的表单的机器设置?顺便说一下,我试图改变形式AutoScaleMode属性,但它没有工作。
如果真的很感激,任何帮助。
我有一个asp.net核心Web服务,它需要正确处理对象的接口属性(必须找出用于对JSON字符串反序列化的实现)。
因此,我创建了一个从interface-Attribute调用的类,例如:
[JsonConverter(typeof(InterfaceJsonConverter<IInputFormat>))]
public interface IInputFormat
{
// ...
}
Run Code Online (Sandbox Code Playgroud)
定义InterfaceJsonConverter的模型类必须是不支持程序集加载的.NET Standard 1.4。但是,该技术用于找出哪个程序集具有Interface的实现,以及哪个实现最接近json-object。(我当然可以将接口直接添加到类中,而不用读取程序集,但我想要一个动态解决方案,我将永远不会错过任何实现)
(最初,我是在.net 4.6中开发的,在那儿效果很好)。
所以我现在想做的是:
有什么办法可以存档吗?还是有更好的方法来处理ASP.NET Core中的接口?
出于完整性考虑,我将发布InterfaceJsonConverter的代码
public class InterfaceJsonConverter<T> : Newtonsoft.Json.JsonConverter
{
public InterfaceJsonConverter()
{
this.DerivedTypes = GetTypesOfImplementedInterfaces(typeof(T));
}
readonly HashSet<Type> derivedTypes = new HashSet<Type>();
public InterfaceJsonConverter(params Type[] types)
{
this.DerivedTypes = types;
}
public InterfaceJsonConverter(System.Reflection.Assembly assembly, string @namespace)
{
this.DerivedTypes = GetTypesInNamespace(assembly, @namespace);
}
private Type[] GetTypesOfImplementedInterfaces(Type type)
{
var parts = type.AssemblyQualifiedName.Split(',');
var assemblyName = parts[1].Trim();
var assemblies = …Run Code Online (Sandbox Code Playgroud) 我正在使用UWP AudioGraph API生成音调,如SDK示例中的音频创建.它工作正常,但我正在尝试添加平移.我可以让它一直平移到左扬声器,但不是一直向右.例如,
leftEmitter = new AudioNodeEmitter(AudioNodeEmitterShape.CreateOmnidirectional(),
AudioNodeEmitterDecayModel.CreateCustom(1, 1),
AudioNodeEmitterSettings.DisableDoppler);
leftEmitter.Position = new System.Numerics.Vector3(-1, 0, 0);
leftEmitter.Gain = 1;
frameInputNodeLeft = graph.CreateFrameInputNode(nodeEncodingProperties, leftEmitter);
frameInputNodeLeft.AddOutgoingConnection(deviceOutputNode);
Run Code Online (Sandbox Code Playgroud)
这将位置设置为x = -1,y = 0和z = 0.它只出自左扬声器,这很好,但它是相反的,
leftEmitter.Position = new System.Numerics.Vector3(1, 0, 0);
Run Code Online (Sandbox Code Playgroud)
这是两个扬声器,这是为什么?也许我误解了坐标系?我也在使用耳机,所以不要误会它是从哪里出来的.
缺口.
PS:我也在尝试从左到右进行实时平移,我从这个位置开始,
leftEmitter.Position = new System.Numerics.Vector3(-100, 0, 10)
Run Code Online (Sandbox Code Playgroud)
每次渲染帧时我都会在X位置加0.1,它会让我在左扬声器中一直听到它,慢慢地向右移动,但是,它会在中间点之后被卡住,至少这听起来像是什么.它不会比这更进一步.
示例代码:
c# ×10
.net-core ×2
asp.net-core ×2
ajax ×1
gdi+ ×1
jquery ×1
linux ×1
officewriter ×1
rdlc ×1
self-hosting ×1
service ×1
signalr ×1
winforms ×1
xamarin ×1
xaml ×1