小编Col*_*e W的帖子

C#Regex for Guid

我需要解析一个字符串并在每个Guid值周围添加单引号.我以为我可以使用正则表达式来做这件事,但我不是一个正则表达式的大师.

是否有一个很好的正则表达式来识别Guid?

我的第二个问题是,一旦我找到了一个有效的正则表达式,我假设我会使用Regex.Replace(String, String, MatchEvaluator)但我不太确定语法.也许是这样的:

return Regex.Replace(stringToFindMatch, GuidRegex, match =>
{
    return string.Format("'{0}'", match.Groups[0].ToString());
});
Run Code Online (Sandbox Code Playgroud)

我正在尝试解析的字符串可能如下所示:

"SELECT passwordco0_.PASSWORD_CONFIG_ID as PASSWORD1_46_0_,FROM PASSWORD_CONFIG passwordco0_ WHERE passwordco0_.PASSWORD_CONFIG_ID = baf04077-a3c0-454b-ac6f-9fec00b8e170; @ p0 = baf04077-a3c0-454b-ac6f-9fec00b8e170 [Type:Guid(0)]"

c# regex

112
推荐指数
7
解决办法
10万
查看次数

C#日志记录.我该怎么用?

我正在寻找一种新的统一日志记录解决方案,用于我们的新系列产品,我想看看Stack Overflow上的一些人的想法.我们需要记录各种应用程序:ASP .net,Windows服务,Web服务,wpf应用程序等.我们只是一个Windows商店.

我们对日志记录解决方案的一些要求包括:

1)日志文件管理

- Ability to split files up over a certain size
- Ability to auto archive/delete after certain period of time
Run Code Online (Sandbox Code Playgroud)

2)能够发送关于记录的某些类型的消息的电子邮件(例如错误)

3)能够将消息写入Windows事件日志

- We need to be able to specify where it's being written in the event log. 
  It would also be nice if it would automatically create the event log source if it does exist.
Run Code Online (Sandbox Code Playgroud)

我已经开始关注nLog,windows trace和log4net.我不仅限于这3只,只是在搜索时出现了很多.

c# windows logging

28
推荐指数
3
解决办法
6504
查看次数

使用Adobe Acrobat静默打印PDF

当我尝试使用adobe acrobat在C#中静默打印pdf时,我遇到了两个问题.我正在使用Process.Start()打印pdf.

第一个问题是,如果没有指定可执行文件的完整路径,我就无法启动Adobe Acrobat.我假设它在安装时不会将其添加到您的路径中. 有没有一种简单的方法可以在机器上启动最新版本的acrobat而无需指定完整路径名? 我担心客户端会进行更新并破坏启动它的代码.我也关心他们在具有不同版本的Windows的机器上安装它(安装路径在64位环境与32位不同).

我的第二个问题是,无论何时我启动acrobat并打印它仍然会打开acrobat窗口.我认为我使用的命令行参数会抑制所有这些,但显然不是.

我正在尝试使用以下语法从命令行启动adobe acrobat:

C:\ Program Files(x86)\ Adob​​e\Reader 10.0\Reader> AcroRd32.exe/t"Label.pdf""HP4000""HP LaserJet 4100 Series PCL6""out.pdf"

它打印出来很好但它仍然离开了acrobat窗口. 除了外出并以编程方式杀死进程之外还有其他解决方案吗?

c# acrobat

17
推荐指数
4
解决办法
6万
查看次数

在TFS中使用NuGet获取内部和外部依赖关系

我目前正在寻找NuGet来解决我在TFS中的依赖问题,我想要做的是托管我自己的NuGet服务器,它将负责内部依赖.我也想使用NuGet来处理我的第三方依赖.我正在尝试为我们公司设置自动构建,这是我试图用NuGet克服的一个障碍.

所以我的问题是如何处理这种情况,我必须从不同的服务器检索我的依赖项?

有没有更好的方法来处理内部依赖?别人怎么做这个?

另外,作为一个注释,我打算使用NuGet而不将包提交给TFS.我计划使用本文中的方法大纲:

http://blog.davidebbo.com/2011/08/easy-way-to-set-up-nuget-to-restore.html

version-control tfs tfsbuild nuget nuget-server

15
推荐指数
1
解决办法
3780
查看次数

Ninject ActivationException:激活IAlertManagement时出错

我收到以下错误:

Test method: BootStrapperTest.Can_Create_Alert_Management_Object threw exception:  Ninject.ActivationException: 
Error activating IAlertManagement No matching bindings are available, and the type is not self-bindable. 

Activation path:   
1) Request for IAlertManagement

Suggestions:    
1) Ensure that you have defined a binding for IAlertManagement.    
2) If the binding was defined in a module, ensure that the module has been loaded into the kernel.    
3) Ensure you have not accidentally created more than one kernel.    
4) If you are using constructor arguments, ensure that the parameter name …
Run Code Online (Sandbox Code Playgroud)

c# ninject tfsbuild ninject-extensions

9
推荐指数
1
解决办法
4969
查看次数

tfs构建定义没有drop文件夹

我最近改变了一些我的版本没有drop文件夹但现在我在执行此操作时遇到以下错误:

The drop location for this build was empty. The build definition 'My Nightly Build' (or the build request) must specify a valid UNC path as the drop location for the build. Update the build definition and try again.

这就是我改变它的方式:

在此输入图像描述

错误:

在此输入图像描述

我可以不使用此配置或我在这里做错了吗?

build-automation tfs tfs2010

9
推荐指数
1
解决办法
3422
查看次数

SQL Real vs Float

假设我有以下2个查询:

select sum(cast(2666 as float)) * cast(.3 as float)
select sum(cast(2666 as real)) * cast(.3 as real)
Run Code Online (Sandbox Code Playgroud)

第一个查询返回:799.8
第二个查询返回:799.800031781197

为什么第二个查询不会返回与第一个相同的东西?

sql sql-server

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

nhibernate queryover LIKE with expression trees

我想在我的基础存储库类中添加一个方法,允许我使用LIKE表达式,但我不太清楚如何解决这个问题.我想创建一个通用方法,查看传入的表达式树,并在传入的字符串值中查找通配符.然后,它将相应地生成QueryOver语句.

我目前有以下内容:

public IList<T> FindAll(Expression<Func<T, bool>> criteria, char wildCard)
{
    return SessionFactory.GetCurrentSession()
            .QueryOver<T>()
            .Where(criteria)
            .List();
}
Run Code Online (Sandbox Code Playgroud)

显然,困难的部分尚未到来.我需要查看表达式树并QueryOver动态构建查询.寻找关于如何继续这一点的一些指示.或者我只是在这里浪费时间,应该在我的存储库中创建处理LIKE查询的单个方法?

附加标准

理想情况下,我想区分以下内容:

  • 搜索*
  • *搜索
  • *搜索*

所以生成的查询将是:

  • 字段LIKE'search%'
  • 字段LIKE'%search'
  • 字段LIKE'%search%'

c# nhibernate queryover

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

单元测试中的C#未捕获异常

我在调试单元测试时遇到了一个非常奇怪的问题.如果我调试单元测试(ctrl + r ctrl + t)我得到一个未捕获的异常.如果我只是运行单元测试(ctrl + rt),我不会得到这个例外.

未捕获的异常是NHibernate.ByteCode.ProxyFactoryFactoryNotConfiguredException.

堆栈跟踪:

at NHibernate.Bytecode.AbstractBytecodeProvider.get_ProxyFactoryFactory() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Bytecode\AbstractBytecodeProvider.cs:line 32
at NHibernate.Validator.Util.NHibernateHelper.IsProxyFactoryConfigurated()
Run Code Online (Sandbox Code Playgroud)

我用.Net Reflector来查看定义这个方法的程序集(NHibernate.Validator ......它的开源代码),这里是"抛出"异常的方法:

public static bool IsProxyFactoryConfigurated()
{
    try
    {
        IProxyFactoryFactory proxyFactoryFactory = Environment.BytecodeProvider.ProxyFactoryFactory;
        return true;
    }
    catch (ProxyFactoryFactoryNotConfiguredException)
    {
        return false;
    }
}
Run Code Online (Sandbox Code Playgroud)

如何通过Try Catch块捕获此异常?

c# nhibernate exception-handling exception visual-studio-2010

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

将't''f'转换为布尔值时,流畅的nhibernate错误"字符串未被识别为有效的布尔值."

使用布尔列从数据库获取记录时遇到问题.我无法改变数据库结构.
数据库类型是Character(1)(PostgreSQL),其中't'表示true,'f'表示false.我使用过PostgreSQLDialect.

我试过把它放在hibernate配置中

 <property name="query.substitutions">1 't',0 'f'</property>
Run Code Online (Sandbox Code Playgroud)

我试图用方言覆盖

 public override string ToBooleanValueString(bool value)
        {
            return value ? "t" : "f";
        }
Run Code Online (Sandbox Code Playgroud)

映射是:

Map(x => x.IsTemplate).Column("template_p");
Run Code Online (Sandbox Code Playgroud)

仍然没有工作,任何帮助?

c# nhibernate fluent-nhibernate

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