小编Mar*_*ark的帖子

在Quartz.NET中有没有办法设置一个只允许一个Job实例运行的属性?

我有一个每X分钟运行一次的服务.如果由于某些不可预见的原因,该作业的耗时超过X分钟,我想确保触发器不会启动此作业的第二个实例.

示例场景

  • 我有Job X,拿起文件,每隔1分钟由Quartz触发.
  • 作业X通常可以在1分钟内处理100个文件,超过100个文件的任何时间都需要超过1分钟.
  • 自上次运行时起,150个文件恰好在那里,因此Job X启动并开始处理.当达到1分钟时,处理了100个文件,剩下50个文件,并且作业X继续运行.
  • 然而,Job X的第二个实例被启动,因为触发器每1分钟触发一次.
  • 我现在有2个Job X实例获取相同的50个文件.

有没有办法连接Quartz.NET只允许1个Job的实例?我可以用第二个触发器等待第一个触发完成,或者我也可以选择跳过第二个触发器,因为它会在一分钟内再次触发.



我看了一下Quartz API的Java版本,发现了一个属性' DisallowConcurrentExecution ',但是在.NET版本中找不到类似的东西.

我的Quartz.NET实现代码

public IScheduler Scheduler { get; set; }
public IJobListener AutofacJobListener { get; set; }

public void Start()
{
var trigger = TriggerUtils.MakeMinutelyTrigger(1);
trigger.Name = @"Document Import Trigger";

Scheduler.ScheduleJob(new JobDetail("Document Import", null, typeof(DocumentImportJob)), trigger);
Scheduler.AddGlobalJobListener(AutofacJobListener);
Scheduler.Start();
}

.net quartz.net

33
推荐指数
2
解决办法
2万
查看次数

Visual Studio 2010 SP1性能

我注意到自安装Visual Studio 2010 SP1以来我遇到了巨大的性能问题.它将随机冻结我很多.

在升级之前,我没有使用Visual Studio 2010的性能问题.我运行的唯一附加组件是ReSharper.

我想知道是否有其他人遇到性能问题?如果是这样,你找到了修复它们的方法吗?

performance visual-studio-2010 visual-studio-2010-sp1

21
推荐指数
2
解决办法
8515
查看次数

如何将我的DIV显示在Silverlight应用程序的顶部?

我有一个需要拖放功能的Silverlight应用程序,因为我允许用户拖放文件以上传到系统中.

但是我遇到的问题是导航总是落后于Silverlight应用程序.我尝试打开"无窗口",但不得不将其关闭,因为我丢失了拖放功能(微软不支持)

我需要做些什么来使我的导航显示在silverlight应用程序的顶部(param name ="Windowless"value ="true"不是一个选项,除非有一种方法可以通过拖放使用它)?

Silverlight添加到HTML


<div id="silverlightControlHost" style="float:left; width:400px; height:300px;">
    <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="220px">
      <param name="source" value="../ClientBin/FileImport.xap"/>
      <param name="onError" value="onSilverlightError" />
      <param name="background" value="white" />
      <param name="minRuntimeVersion" value="4.0.50826.0" />
      <param name="autoUpgrade" value="true" />

      <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none">
           <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
      </a>
    </object>
    <iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>
</div>


导航菜单


<div id="NavigationControl">
    <ul class="sf-menu sf-js-enabled sf-shadow">
        <li><a id="Navigation_1" href="...">Item 1</a></li>
        <li class="sfHover"><a id="Navigation_2" class="sf-with-ul">Item 2<span class="sf-sub-indicator">»</span></a>
            <ul style="visibility: visible; display: block;">
                <li><a id="Navigation0_1" …

silverlight superfish silverlight-4.0

8
推荐指数
1
解决办法
3988
查看次数

参数的执行速度不如硬编码值

我有一个执行非常糟糕的存储过程.当我声明一个变量时,设置它的值,然后在where子句中使用它,该语句需要一个多小时才能运行.当我在where子句中对变量进行硬编码时,它会在不到一秒的时间内运行.

我开始通过执行计划调查它出了什么问题.看起来当我尝试传递一些声明的变量时,执行计划会创建一些Hash Match,因为它从使用UNION和公用表表达式的视图中选择值.

/*************   Begin of Stored Procedure ***************/
CREATE PROCEDURE GetFruit
  @ColorId bigint,
  @SeasionId bigint
WITH RECOMPILE
AS
BEGIN

SELECT
    A.Name
FROM
    [Apple_View] A   /* This is the view down below */
    INNER JOIN [Fruit] F
        ON ( F.ColorId = @ColorId
            AND A.FruitId = F.FruitId)          
WHERE
    (A.ColorId = @ColorId
    AND 
    A.SeasonId = @SeasonId)

END
/************* End of Stored Procedure   ***************/

/************* Begin of View   ***************/
WITH Fruits (FruitId, ColorId, SeasonId) AS
(
    -- Anchor member
    SELECT
        F.FruitId
        ,F.ColorId
        ,F.SeasonId …

sql t-sql sql-server stored-procedures sql-server-2005

7
推荐指数
1
解决办法
3502
查看次数

我是否正确使用AutoFac注册ObjectContext?

我有一个Windows服务,我想确保我的EF ObjectContext在每次运行之间被处理掉.每次执行时,服务运行的时间都会更长.似乎ObjectContext不断增长.我的ObjectContext应该注册不同还是我做错了什么?

我正在做什么的概述.

  • 我正在使用Quartz.NET来安排我的服务
  • 我正在使用Atlas来配置和设置我的Windows服务
  • 我正在使用Autofac作为我的IoC
  • 我正在使用Entity Framework作为我的数据模型

Walkthru的代码:

  • 因此,该计划通过使用Atlas注册服务开始.
  • Atlas将注册我的autofac注册,这些注册位于模块MyModule中
  • MyModule在InstancePerLifetimeScope中注册ObjectContext(这是正确的范围?),然后它将我的自定义UnitOfWork的一个实例作为InstancePerLifetimeScope(这是正确的范围?).
  • MyService由Atlas托管,它获取Quartz调度程序和AutofacJobListener属性,并在服务启动时调度作业(MyJob)每5分钟运行一次.
  • MyJob从AutofacJobListener中获取ObjectContext属性的实例.这个工作呼唤数据库,让我得到我的东西.

当作业运行时,它会在每次运行时调出并获取我的东西需要更长的时间(例如:第一次运行时为2分钟,第二次运行服务时为4分钟,下一次为6分钟,下一次为8,依此类推) .看起来我的ObjectContext每次都变得越来越大.它拉动的数据没有改变,行数和列数仍然相同.所以我认为我的注册错了,是这样的吗?如果没有,你能看到我正在做的事情的问题吗?

程序

static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    static void Main(string[] args)
    {
        var configuration =
            Host.Configure<MyService>(c =>
            {
                c.AllowMultipleInstances();
                c.WithRegistrations(b => b.RegisterModule(new MyModule()));
            }, args);
        Host.Start(configuration);
    }
}
Run Code Online (Sandbox Code Playgroud)

public class MyModule : Module
{
    protected override void Load(ContainerBuilder builder)
    {
        LoadQuartz(builder);
        LoadServices(builder);

        LoadInfrastructure(builder);
    }

    private void LoadInfrastructure(ContainerBuilder …
Run Code Online (Sandbox Code Playgroud)

.net autofac atlas quartz.net entity-framework-4

6
推荐指数
1
解决办法
1724
查看次数

C#DateTime.AddMonth,下个月不存在日期

如果我有DateTime date = new DateTime("1/31/2010");,我打电话date.AddMonth(1).我会得到"2/28/2010"还是会因为"2/31/2010"不存在而吓坏了?或者我会得到"2010年3月3日"?

(我也不在Visual Studio附近的计算机上)

c# asp.net datetime

5
推荐指数
2
解决办法
8308
查看次数

为什么我的实体框架将'2.87'变成'2'(十进制字段)?

我确认正确的值'2.87'进入服务..并且根据EF图表,'Score'字段的类型是'Decimal'...但是在数据库中它只是'2'

   [OperationContract]
        public void AddHighScore(string strName, decimal dScore, int iLevel)
        {
            using (SQL2008R2_789485_punkouterEntities1 dc = new SQL2008R2_789485_punkouterEntities1())
            {
                HighScore oHighScore = new HighScore();
                oHighScore.Level = iLevel;
                oHighScore.Name = strName;
                //oHighScore.Name = dScore.ToString();
                oHighScore.Score = dScore;
                dc.AddToHighScores(oHighScore);
                dc.SaveChanges();
            }
        }


-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'HighScores'
CREATE TABLE [dbo].[HighScores] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(max)  NOT NULL,
    [Score] decimal(18,0)  NOT NULL,
    [Level] int  NOT NULL
);
GO
Run Code Online (Sandbox Code Playgroud)

sql t-sql precision entity-framework decimal

5
推荐指数
2
解决办法
5995
查看次数

javascript 添加会产生奇怪的小数问题

可能的重复:
JavaScript 浮点数问题的优雅解决方法

为什么使用javascript将2个数字相加时,会返回疯狂的小数点数?

如果我在纸上加上 285.72 + 142.86 它等于 428.58,你用计算器得到同样的答案。

但是,如果我从 2 个文本框中添加该数字,它将返回 428.58000000000004

例子

我需要我的 javascript 返回 428.58。我知道我可以使用 .toFixed(),但我不想使用,因为我不明白为什么将两个数字相加会在小数点后产生如此疯狂的数字。

javascript decimal addition

5
推荐指数
1
解决办法
3034
查看次数

IE7 ReportViewer控件

我有一个我建立的网站,适用于IE8/IE9,Chrome和FireFox中的每个人.但是,现在我的客户端要求在IE7中工作,因为机器仍然有IE7.我无法弄清楚ReportViewer控件有什么问题.任何帮助,将不胜感激.

问题是我的报告超出了设定的高度和宽度; 它不会留在我使用jQuery包裹它的DIV中

jQuery代码

 $(document).ready(function () {
            var htmlwidth = $('.main').width() - 20;
            var htmlheight = $(document).height() - $('.header').height() - 45;
            $('#<%= ReportViewer1.ClientID %>').wrap('<div style="overflow:auto;" />');
            $('#<%= ReportViewer1.ClientID %>').parent().css(height, htmlheight);
            $('#<%= ReportViewer1.ClientID %>').parent().css('width', htmlwidth);
            $('#<%= ReportViewer1.ClientID %>').css('width', htmlwidth);
            $('#<%= ReportViewer1.ClientID %>').css(height, htmlheight);
            $('#<%= ReportViewer1.ClientID %>').parent().css('border', 'solid 1px Black');
    });
Run Code Online (Sandbox Code Playgroud)

内容

<asp:ScriptManager ID="scManager" runat="server"></asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Height="100%"  Width="100%"
    SizeToReportContent="true" ZoomMode="Percent" AsyncRendering="false" >
</rsweb:ReportViewer>
Run Code Online (Sandbox Code Playgroud)

示例生成块{content + jQuery Code}

<div style="width:500px; overflow:auto; border:solid 1px Black;height:400px;">
    <asp:ScriptManager ID="scManager" runat="server"></asp:ScriptManager>
    <rsweb:ReportViewer ID="ReportViewer1" runat="server" Height="400px" …
Run Code Online (Sandbox Code Playgroud)

html reportviewer2008 internet-explorer-7

3
推荐指数
1
解决办法
1377
查看次数

无法加载类型'Common.Logging.Factory.AbstractCachingLoggerFactoryAdapter'

我刚刚更新了我的nuget包Common.Logging.Log4Net.从那时起,我不断收到以下错误:

无法从程序集'Common.Logging,Version = 2.2.0.0,Culture = neutral,PublicKeyToken = af08829b84f0328e'加载类型'Common.Logging.Factory.AbstractCachingLoggerFactoryAdapter'

以下是链接到的每个nuget包的列表Common.Logging以及版本:

  • Common.Logging - 2.2.0
  • Common.Logging.Core - 2.2.0
  • Common.Logging.Log4Net - 2.0.1

在我的web.config中,我有以下几点:

<configuration>
  <configSections>
   <sectionGroup name="common">
      <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
    </sectionGroup>
  </configSections>

  //...//

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

  //...//

  <common>
    <logging>
      <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net">
        <arg key="configType" value="FILE-WATCH" />
        <arg key="configFile" value="~/log4net.config" />
      </factoryAdapter>
    </logging>
  </common>
</configuration>
Run Code Online (Sandbox Code Playgroud)

我怎样才能解决这个问题?

我试过改变:

<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net">
Run Code Online (Sandbox Code Playgroud)

to(添加版本的Common.Logging.Log4net.dll [201])

<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4net201">
Run Code Online (Sandbox Code Playgroud)

那不起作用.

log4net nuget common.logging

2
推荐指数
1
解决办法
3557
查看次数