我有一个嵌入了Quartz.Net的Windows服务,但似乎找不到在Quartz.Net作业中创建对实例化对象的引用的方法......
当Windows服务启动时,它会实例化一些对象以进行日志记录,数据库访问和其他目的,因此我希望我的Quartz.Net作业使用这些已经实例化的对象,而不是创建自己的这些对象实例.但是,Quartz.Net作业由调度程序使用无参数构造函数实例化,因此无法使用构造函数传递引用.
我是否必须创建自己的JobFactory实现,这是实现此目的的唯一方法吗?
public static string ToTrimmedString(this DataRow row, string columnName)
{
return row[columnName].ToString().Trim();
}
Run Code Online (Sandbox Code Playgroud)
编译正常,但它不会出现在DataRow的intellisense中......
我有一个引用另一个程序集(类库)的Windows服务.在这个其他程序集中,我使用Application Settings来存储一些值.当我将所有必需的文件复制到服务器时,我可以在AssemblyName.dll.config文件中看到这些设置.
但是,当我更改此配置文件中的设置并重新启动服务时,更改无效.即使我卸载/重新安装该服务,它仍然会在运行时返回旧值.
配置文件:
<setting name="RecordLimit" serializeAs="String">
<value>300</value>
</setting>
Run Code Online (Sandbox Code Playgroud)
码:
if (recordCount > Settings.Default.RecordLimit) //always 300
Run Code Online (Sandbox Code Playgroud)
因此,即使我将配置文件中的值更改为400并重新启动甚至重新安装服务,该值始终为300,这使我认为此值存储在已编译的代码中并从其中返回.
我做错了什么,应用程序设置的更改总是需要重新编译并重新安装(我知道我可以使用Save()方法从代码更改设置但这是一个Windows服务,所以使用此方法似乎没有感)?
如果存储在配置文件中的这些设置无效并且设置存储在已编译的代码中,我可以安全地删除这些配置文件吗?
如果没有重新编译我必须存储的其他选项设置,我可以更改这些设置,而无需重新编译?
编辑:我刚刚删除了AssemblyName.dll.config文件,代码返回300,所以配置文件显然是无关紧要的.
是否可以在没有实体框架和实体框架迁移的情况下使用 ASP.NET Identity?我的应用程序的其余部分将使用 Micro ORM 进行数据访问。但是,该应用程序使用内置的 ASP.NET 标识个人用户帐户。
我的目标是仍然能够使用内置的 UserManager 和 LoginManager 类,并另外检索使用 Micro ORM 的用户列表,并消除与 EF/Migrations 相关的任何事情。这可能吗?似乎并非如此,因为原始数据库结构是通过应用初始迁移创建的。
如果有人有这样做的好技术,请分享。
我有以下地图用于转换SQL Server类型,SQLData类型和.NET类型:
/// <summary>
/// The map of types. THis maps all the corresponding types between sql server types, .net sql types, and .net types
/// </summary>
public static List<SqlTypeConversionHolder> TypeList = new List<SqlTypeConversionHolder>()
{
new SqlTypeConversionHolder("bigint", typeof(SqlInt64),typeof(Int64)),
new SqlTypeConversionHolder("binary", typeof(SqlBytes),typeof(Byte[])),
new SqlTypeConversionHolder("bit", typeof(SqlBoolean),typeof(Boolean)),
new SqlTypeConversionHolder("char", typeof(SqlChars),typeof(char)), //this one may need work
new SqlTypeConversionHolder("cursor", null,null),
new SqlTypeConversionHolder("date", typeof(SqlDateTime),typeof(DateTime)),
new SqlTypeConversionHolder("datetime", typeof(SqlDateTime),typeof(DateTime)),
new SqlTypeConversionHolder("datetime2", null,typeof(DateTime)),
new SqlTypeConversionHolder("DATETIMEOFFSET", null,typeof(DateTimeOffset)),
new SqlTypeConversionHolder("decimal", typeof(SqlDecimal),typeof(Decimal)),
new SqlTypeConversionHolder("float", typeof(SqlDouble),typeof(Double)),
//new SqlTypeConversionHolder("geography", typeof(SqlGeography),typeof(null));
//new SqlTypeConversionHolder("geometry", typeof(SqlGeometry),typeof(null));
//new …Run Code Online (Sandbox Code Playgroud) 我从这个论坛得到了这个示例代码.
<DatePicker SelectedDate="{Binding myVideModelProperty}"
Height="25" HorizontalAlignment="Left" Margin="81,-2,0,0" Name="myDatePicker" VerticalAlignment="Top" Width="115">
<DatePicker.Resources>
<Style TargetType="{x:Type DatePickerTextBox}">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<TextBox x:Name="PART_TextBox"
Text="{Binding Path=SelectedDate, RelativeSource={RelativeSource AncestorType={x:Type DatePicker}}, StringFormat={}{0:yyyy/MM/dd}}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DatePicker.Resources>
</DatePicker>
Run Code Online (Sandbox Code Playgroud)
但我希望格式即yyyy/MM/dd来自名为dateformat的应用程序属性.你能帮我把stringformat作为绑定到application属性吗?
我有这个示例代码:
static void Main(string[] args) {
var t1 = Task.Run(async () => {
Console.WriteLine("Putting in fake processing 1.");
await Task.Delay(300);
Console.WriteLine("Fake processing finished 1. ");
});
var t2 = t1.ContinueWith(async (c) => {
Console.WriteLine("Putting in fake processing 2.");
await Task.Delay(200);
Console.WriteLine("Fake processing finished 2.");
});
var t3 = t2.ContinueWith(async (c) => {
Console.WriteLine("Putting in fake processing 3.");
await Task.Delay(100);
Console.WriteLine("Fake processing finished 3.");
});
Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)
控制台输出让我困惑:
我试图将任务链接起来,以便一个接一个地执行,我做错了什么?我不能使用等待,这只是示例代码,实际上我正在排队传入的任务(一些是异步的,一些不是)并且希望以它们进入的相同顺序执行它们但没有并行性,ContinueWith似乎比创建更好一个ConcurrentQueue并自己处理每一个,但它只是不起作用...
如果表的PK是标准的自动增量int(Id),并且检索和更新的记录几乎总是接近最大Id,那么无论PK聚簇索引是按升序还是按顺序排序,它都会在性能方面产生任何差异.降?
当创建这样的PK时,SSMS默认将索引的排序顺序设置为升序,并且因为访问最多的行总是接近当前最大Id的行,我想知道将排序更改为降序是否会加快检索速度因为记录将自上而下排序而不是自下而上,并且最常访问靠近顶部的记录.
我在输入字段中有几个TextBox,在我的视图中有一个"Save"按钮.其中两个TextBox是保存所必需的字段,我在xaml中设置了一个自定义ValidationRule,用于一些视觉反馈(红色边框和工具提示),如下所示:
<TextBox ToolTip="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}">
<TextBox.Text>
<Binding Path="ScriptFileMap" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<v:MinimumStringLengthRule MinimumLength="1" ErrorMessage="Map is required for saving." />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
Run Code Online (Sandbox Code Playgroud)
"保存"按钮链接到一个调用SaveScript()函数的DelegateCommand.如果两个必填字段的属性为空,则该函数不允许用户保存:
public void SaveScript()
{
if (this.ScriptFileName.Length > 0 && this.ScriptFileMap.Length > 0)
{
// save function logic
}
}
Run Code Online (Sandbox Code Playgroud)
但是,该功能仍允许保存文件.仔细观察,我发现当ValidationRule失败时,这两个字段(ScriptFileName和ScriptFileMap)的值没有被更新,并且它超过了最后的已知值.
这是ValidationRule的预期行为还是我在某处丢失了某些东西或出现故障?如果是前者,有没有办法覆盖这种行为?如果空字符串永远不会传递给bound属性,我无法阻止ViewModel中的保存.
有没有办法将Visual Studio 2015诊断工具事件选项卡中显示的事件列表保存到文件?
c# ×5
.net ×3
sql-server ×2
wpf ×2
asp.net ×1
asp.net-core ×1
date-format ×1
quartz.net ×1
rdbms ×1
sorting ×1
sql ×1
sqldatatypes ×1
task ×1
types ×1
vb.net ×1
xaml ×1