小编Ian*_*ien的帖子

使用Quartz .NET创建Cron表达式

是否可以使用Quartz .NET程序集生成cron表达式?我看到CronScheduleBuilder班上有一个私人会员cronExpression,基本上就是我要找的.有没有其他方法可以获得cron表达式?

.net c# cron quartz-scheduler quartz.net

4
推荐指数
1
解决办法
4192
查看次数

如何在SQL MERGE语句中使用GROUP BY子句?

我想合并两个表,我想使用GROUP BY来修复以下错误:

The MERGE statement attempted to UPDATE or DELETE the same row more than once. This happens when a target row matches more than one source row. A MERGE statement cannot UPDATE/DELETE the same row of the target table multiple times. Refine the ON clause to ensure a target row matches at most one source row, or use the GROUP BY clause to group the source rows.

GROUP BY子句到底在哪里?

MERGE dbo.MyTarget targ
USING dbo.MySource src
ON (targ.Identifier = src.Identifier …
Run Code Online (Sandbox Code Playgroud)

sql t-sql merge group-by

4
推荐指数
1
解决办法
4996
查看次数

编写一个cron表达式,每15分钟执行一次

我正在尝试设置一个cron作业,在我的会话目录中每15分钟运行一次垃圾收集器,以清除超出我在php.ini中设置的一个子目录位置的到期限制的会话.我之前从未使用过cron工作,所以我想知道是否有人可以帮助我.

到目前为止我所拥有的是:

15 * * * * /home/yadda/something/etc 
Run Code Online (Sandbox Code Playgroud)

cron session

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

为什么System.String.EndsWith()有一个char重载而System.String.StartsWith()没有?

我正在浏览System.String,我想知道为什么EndsWithStartsWith方法在参数方面不对称.

具体来说,为什么不System.String.EndsWith支持char参数System.String.StartsWith?这是因为任何限制或设计特征吗?

// System.String.EndsWith method signatures
[__DynamicallyInvokable]
public bool EndsWith(string value)

[ComVisible(false)]
[SecuritySafeCritical]
[__DynamicallyInvokable]
public bool EndsWith(string value, StringComparison comparisonType)

public bool EndsWith(string value, bool ignoreCase, CultureInfo culture)

[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
internal bool EndsWith(char value)
{
  int length = this.Length;
  return length != 0 && (int) this[length - 1] == (int) value;
}

// System.String.StartsWith method signatures
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] …
Run Code Online (Sandbox Code Playgroud)

.net c# string char

4
推荐指数
1
解决办法
1119
查看次数

如何在PowerShell C#cmdlet中使用WriteProgressCommand?

更新.cmdlet在Visual Studio 2010中使用C#/ .Net 4.0 创建了一个PowerShell 3.0 .它工作正常.但cmdlet需要一段时间,我想添加一个进度条.

关于WriteProgressCommand的MSDN文档含糊不清.这是链接:http://msdn.microsoft.com/en-us/library/microsoft.powershell.commands.writeprogresscommand.completed(v=vs.85).aspx

下面的代码显示了我想要做的事情.基本上做一些处理ProcessRecord().然后每秒更新进度条.不确定如何显示进度条.救命?

[System.Management.Automation.Cmdlet(System.Management.Automation.VerbsCommon.Get, "StatusBar")]
public class GetStatusBarCommand : System.Management.Automation.PSCmdlet
{
    /// <summary>
    /// Provides a record-by-record processing functionality for the cmdlet.
    /// </summary>
    protected override void ProcessRecord()
    {
        WriteProgressCommand progress = new WriteProgressCommand();

        for (int i = 0; i < 60; i++)
        {
            System.Threading.Thread.Sleep(1000);
            progress.PercentComplete = i;
        }

        progress.Completed = true;
        this.WriteObject("Done.");
        return;
    }
}

// Commented out thanks to Graimer's answer …
Run Code Online (Sandbox Code Playgroud)

c# powershell .net-4.0

4
推荐指数
1
解决办法
2388
查看次数

在Areas之外的MVC应用程序中托管WCF服务

我有一个MVC项目,在根目录中添加了一个名为WCF的文件夹。在此文件夹中,我创建了一个名为的WCF服务CustomFunctions。当我尝试启动该服务时,出现以下错误:

错误:无法从http://localhost/Viper/WCF/CustomFunctions.svc... 获取元数据。元数据包含无法解析的引用:

附加说明:

找不到类型'Viper.WCF.CustomFunctions',作为ServiceHost指令中的Service属性值提供,或在配置元素system.serviceModel / serviceHostingEnvironment / serviceActivations中提供。

我昨天遇到此错误,并花了一些时间在互联网上寻找答案。这使我对Web.config和Global.asax.cs进行了很多更改。昨天,它开始工作了,我停了下来。但是,当我今天早上回来时,它并没有再全部工作。在此期间,没有添加任何新内容,也没有更改任何代码。

我已经将以下内容添加到我的Web.config中:

<system.serviceModel>
<services>
  <service behaviorConfiguration="WCFBehavior" name="Viper.WCF.CustomFunctions">
    <endpoint address="" binding="wsHttpBinding" contract="Viper.WCF.ICustomFunctions">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/Viper/WCF/CustomFunctions/" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="WCFBehavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" httpGetUrl=""/>
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel> 
Run Code Online (Sandbox Code Playgroud)

这给我Global.asax.cs

public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.svc/{*pathInfo}");

        routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // …
Run Code Online (Sandbox Code Playgroud)

c# model-view-controller wcf web-services metadata

4
推荐指数
1
解决办法
2697
查看次数

如何在C#中撤消和重做(富文本框)

我一直试图在我的文本编辑器中进行撤消重做大约3天.它正在努力.

我有一个文本框(命名richTextBoxPrintCtrl1),我希望能够撤消和*重做*(逐字逐句).

因此,如果我单击撤消按钮,它将撤消最后一个单词.如果我然后单击重做按钮,它重做最后一个单词.

有人可以帮我搞定吗?

richTextBoxPrintCtrl1.Undo();效果不好.它删除文本框中键入的所有内容.

在此先感谢您的帮助.

我知道这个问题之前已被多次询问过,但是我无法使用我在这里浏览过的问题中的信息.

c# winforms visual-studio-2012

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

我可以使用三元运算符,每个函数返回void吗?

在C#中可以使用没有值的if内联条件,换句话说返回void

public void FuncReturningVoid ()
{
    return;
}

public void AnotherFuncReturningVoid()
{
    return;
}

public void Test ()
{
    int a = 1;
    int b = 2;

    // I whish I could to do this:
    a == b ? FuncReturningVoid() : AnotherFuncReturningVoid();

    //would be the same...
    if (a == b)
    {
        FuncReturningVoid();
    }
    else
    {
        AnotherFuncReturningVoid();
    }
}
Run Code Online (Sandbox Code Playgroud)

c# methods if-statement inline void

4
推荐指数
1
解决办法
2055
查看次数

C#CS0079事件处理编译错误

我无法编译以下代码.

编译错误CS0079:事件'CustomEvent'只能出现在+ =或 - =的左侧

if (CustomEvent != null)   //CS0079
    CustomEvent(null, null);  //CS0079
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

我的实现是这样的:

public delegate void EventHandler(object sender, EventArgs e);  
public static event EventHandler CustomEvent
{
    add    { CustomEvent += value; }
    remove { CustomEvent -= value; }
 }
private static void Func()
{
    if (CustomEvent != null)      //CS0079
        CustomEvent(null, null);  //CS0079
}
Run Code Online (Sandbox Code Playgroud)

.net c# events compiler-errors

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

SQL表定义不正确;只能有一个自动列,并且必须将其定义为键

如果我运行下面的 SQL 命令,我总是会收到此错误:

无效 SQL:CREATE TABLE ms_account (accountid INT NOT NULL auto_increment,accountname VARCHAR(50) NOT NULL,kindofaccount SMALLINT NOT NULL,accountowner VARCHAR(20) NOT NULL,accountcurrency VARCHAR(10) NOT NULL,accountbalance DECIMAL(15,2) NOT NULL,bankid VARCHAR(8) NOT NULL,createdate INT NOT NULL,deletedate INT NOT NULL,changedate INT NOT NULL,删除 SMALLINT NOT NULL,锁定 SMALLINT NOT NULL,PRIMARY KEY accountid (bankid,accountid)) ; :表定义不正确;只能有一个自动列,并且必须将其定义为键

SQL

"CREATE TABLE {$utcv_db_prefix}account (".
"accountid INT NOT NULL auto_increment,".
"accountname VARCHAR(50) NOT NULL,".
"kindofaccount SMALLINT NOT NULL,".
"accountowner VARCHAR(20) NOT NULL,".
"accountcurrency VARCHAR(10) NOT NULL,".
"accountbalance DECIMAL(15,2) NOT NULL,". …
Run Code Online (Sandbox Code Playgroud)

sql mariadb

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