我无法在我的Windows7 x64系统中安装mysql2 gem.我尝试使用32位和64位版本的MySQL服务器,但没有一个让我更进一步.
我安装了Ruby 1.8,开发工具包和Rails平台.我甚至安装了minGW来允许C++/C编译.MySQL Server安装在默认位置.
运行命令时:
C:\Users\Arne>gem install mysql2 -- --with-mysql-include="C:\Program Files (x86)\MySQL\MySQL Server 5.1\include" --with-mysql-lib="C:\Program Files (x86)\MySQL\MySQL Server 5.1\lib\"
Run Code Online (Sandbox Code Playgroud)
我从控制台收到以下输出:
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.
Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir …Run Code Online (Sandbox Code Playgroud) 我目前正在试图弄清楚为什么MSBuild无法编译我们的单元测试dll.问题只出现在这个DLL而不是其他单元测试项目中.
这是我在构建失败时从TeamCity收到的输出:
[10:38:55]: NAnt output:
[10:38:55]: [exec]
[10:38:55]: [exec]
[10:38:55]: [exec] "C:\Robinson\trunk\Projects\Robinson\Robinson.sln" (default target) (1) ->
[10:38:55]: [exec] "C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj" (default target) (19) ->
[10:38:55]: [exec] (CoreCompile target) ->
[10:38:55]: [exec] Modules\SecurityModuleTests.cs(10,30): error CS0234: The type or namespace name 'Modules' does not exist in the namespace 'TenForce.Execution.Web' (are you missing an assembly reference?) [C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]: [exec] Modules\SecurityModuleTests.cs(197,39): error CS0246: The type or namespace name 'SecurityModule' could not be found (are you missing a using directive or an assembly reference?) [C:\Robinson\trunk\Projects\Robinson\TenForceExecutionTests\TenForceExecutionTests.csproj]
[10:38:55]: …Run Code Online (Sandbox Code Playgroud) 我目前正在编写一些单元测试来检查我们编写的ASP MVC应用程序的功能和正确的工作方式.在这个MVC应用程序中,我使用了一个特殊的ActionFilterAttribute,它允许在向MVC应用程序发出请求时进行身份验证.
此ActionFilterAttribute的代码如下:
using System;
using System.Security.Authentication;
using System.Text;
using System.Web.Mvc;
using TenForce.Execution.Framework;
using TenForce.Execution.Api2.Implementation;
namespace TenForce.Execution.Web.Filters
{
     /// <summary>
     /// This class defines a custom Authentication attribute that can be applied on      controllers.
     /// This results in authentication occurring on all actions that are beeing defined in the controller
     /// who implements this filter.
     /// </summary>
     [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
     public class AuthenticationFilter : ActionFilterAttribute
     {
         #region IAuthorizationFilter Members
         /// <summary>
         /// This function …Run Code Online (Sandbox Code Playgroud) 我目前正在编写一个特殊的客户端应用程序,以允许我们的单元测试使用原子提要的XML结构来处理OData接口.一切似乎都正常工作,但是当我需要将DateTime值作为属性传递时,我遇到了麻烦.
我编写了以下代码,从对象的属性中提取DateTime值并以特定格式存储它:
private static void GenerateProperty<T>(StringBuilder xml, T obj, PropertyInfo info)
        {
            // Extract the information about the property if it contains a value.
            if (info.GetValue(obj, null) == null) return;
            string type = info.GetGetMethod().ReturnType.ToString().Split('.').Last();
            string value = info.GetValue(obj, null).ToString();
            if (type == "DateTime")
                value = ((DateTime)info.GetValue(obj, null)).ToString("yyyy-mm-ddThh:mm:ss");
            if (type == "Boolean") value = value.ToLower();
            // Append the property to the generated XML.
            xml.Append(type.ToLower().Equals("string") ? 
                    string.Format("<d:{0}>{1}</d:{0}>", info.Name, value) : 
                    string.Format("<d:{0} m:type=\"Edm.{1}\">{2}</d:{0}>", info.Name, type, value));
        }
Run Code Online (Sandbox Code Playgroud)
代码很反映,但这不是重点.此代码为DateTime返回的值采用以下格式:2011-49-13T11:49:41Z
但是,我从我的OData服务收到以下错误:
处理请求流时出错.将值从请求有效负载转换为属性'Created'到类型'System.DateTime'时遇到错误,这是属性的预期类型.有关详细信息,请参阅内部异常 字符串'2011-49-13T11:49:41Z'不是有效的AllXsd值.System.FormatException在System.Xml.XmlConvert.ToDateTime(字符串s XmlDateTimeSerializationMode …
我在这里碰到了一些奇怪的东西.我有一个"身份验证器"依赖ND5来哈希我们匹配的某个字符串作为密码.我运行测试时的问题是:
NoMethodError: undefined method `md5' for #<CASServer::Authenticators::Billing:0x007fd8e6c906a0>
./models/authenticators/billing.rb:63:in `validate'
./routes/login.rb:166:in `block (2 levels) in <class:Server>'
./routes/login.rb:158:in `each'
./routes/login.rb:158:in `block in <class:Server>'
(eval):2:in `click_button'
./features/step_definitions/when_steps.rb:32:in `/^I enter "(.*)" as username and the generated username password and log in$/'
./features/rubycas.login.feature:14:in `When I enter "username" as username and the generated username password and log in'
Run Code Online (Sandbox Code Playgroud)
所以基本上他不承认MD5是Digest库的一部分.在IDE中以及在IRB控制台中运行测试时会发生此问题:
1.9.3-p125 :001 > require "digest/md5" and Digest::MD5("test")
NoMethodError: undefined method `MD5' for Digest:Module
Run Code Online (Sandbox Code Playgroud)
但是,当我运行以下内容时:
[root@DCUDEV01 /home/morn/rubycas/current]# ruby
require "digest/md5" and Digest::MD5("test")
Run Code Online (Sandbox Code Playgroud)
我没有收到任何错误,转储或异常.Ruby只接受它.为了让这个MD5工作起作用,我缺少什么?
我目前正试图弄清楚如何在我们的ASP.NET应用程序中执行手动Windows身份验证.问题是我们运行了OData服务,并使用FormsAuthentication提供通用登录机制并允许OData的PUT和DELETE谓词,包括表单重定向.
但是,对于某些客户,我们集成了Windows身份验证,以便用户可以使用活动目录顺利集成.现在的问题是我们希望能够在不破坏Odata服务的情况下切换身份验证方法,因为我们依赖它.
我们要做的是使用IhttpModule模仿Windows身份验证机制.到目前为止,我们能够打开和关闭该功能,并且在发出请求时我们会遇到挑战.我不知道的是如何使用从浏览器接收的信息对活动目录执行身份验证:
这是我们用于从当前请求中提取NTLM信息的代码:
/// <summary>
/// <para>Determines whether the current <see cref="HttpRequest"/> is a NTML challenge.</para>
/// </summary>
/// <param name="request">The <see cref="HttpRequest"/> to evaluate.</param>
/// <param name="header">The output header to authenticate.</param>
/// <returns>True if the current <see cref="HttpRequest"/> is considered a NTML challenge.</returns>
 protected bool IsNtlmChallenge(HttpRequest request, out string header)
 {
      const string headerName = @"Authorization";
      if (request.Headers.AllKeys.Contains(headerName))
      {
           header = request.Headers[headerName];
           return true;
      }
      header = string.Empty;
      return false;
 }
Run Code Online (Sandbox Code Playgroud)
这允许我们从请求中提取标头.我现在需要知道的是我如何在活动目录上执行此身份验证.
这是我们用来提取信息的逻辑:
// Check if we need …Run Code Online (Sandbox Code Playgroud) 首先让我为整个主题的篇幅道歉.这将是相当长的,但我希望确保消息清晰而没有错误.
在公司,我们有一个现有的ASP.NET WebApplication.在.NET Framework 3.5 SP1上用C#ASP.NET编写.前段时间,使用WCF和SOAP为此Web应用程序开发了一个初始API,以允许外部各方与应用程序通信,而无需依赖浏览器.
这个API存活了一段时间,但最终请求创建了一个RESTfull并依赖于新技术的新API.我得到了这个任务,我使用Microsoft MVC 2 Framework创建了初始API,在我们的ASP.NET WebApplication中运行.最初安静一段时间才能使其正常运行,但目前我们能够在应用程序上进行REST调用以接收详细说明我们资源的XML.
我参加了一个微软的WebCamp,我立即被OData概念出售.它与我们正在做的非常相似,但这是一个由更多玩家支持的协议,而不是我们自己的实现.目前我正在开发一个PoC(概念证明)来重新创建我使用OData协议和WCF DataService技术开发的API.
在搜索Internet以获取NHibernate 2以使用Data Services之后,我成功创建了一个ReadOnly版本的API,允许我们通过将传入的查询请求映射到我们的Business层来从内部业务层读出实体.但是,我们希望有一个功能API,它也允许使用OData协议创建实体.所以现在我有点坚持如何继续.我一直在阅读以下文章:http://weblogs.asp.net/cibrax/default.aspx?PageIndex = 3
上面清楚地解释了如何将自定义DataService映射到NHibernate层.我已经使用它作为继续的基础,但我有"问题",我不想使用NHibernate将我的请求直接映射到数据库,但我希望将它们映射到我们的业务层(一个单独的DLL) )根据访问权限,权限和触发器执行大量检查,约束和更新.
所以我要问的是,我举例来说,如上所述创建我自己的NhibernateContext类,但是依赖于我们的业务层而不是NHibernate会话,它可以工作吗?我可能不得不依赖反射来计算我在运行时使用的对象的类型,并调用正确的业务类来执行更新和删除.
用小ascii图片演示:
                              *-----------------*
                              *   Database      *
                              *-----------------*
                              *------------------------*
                              * DAL(Data Access Layer) *
                              *------------------------*
                              *------------------------*
                              * BUL (Bussiness Layer)  *
                              *------------------------*
                              *---------------*  *-------------------*
                              * My OData stuff*  * Internal API      *
                              *---------------*  *-------------------*
                                                 *------------------*
                                                 * Web Application  *
                                                 *------------------*
Run Code Online (Sandbox Code Playgroud)
那么,这会起作用,还是性能会使它变得无用?或者我在这里错过了球?我的想法是,我希望重用OData WCF DataService中存储在BUL&DAL层中的任何逻辑.
我正在考虑创建从Data.Services命名空间中的EntityModel类继承的新类,并创建一个新的DataService对象,该对象标记对BUL&DAL和API层的所有调用.但是,我不确定拦截创建和删除资源的请求的位置/对象.
我希望我有点清楚我要解释的内容,我希望有人可以帮助我.
我正在尝试在作为代理的Apache2网络服务器后面设置一个Rails 3应用程序.Apache Web服务器在端口8080上运行,如果我调用http:// ip:8080,我在mongrel窗口中看到请求,因此代理正确地将接收请求中继到mongrel服务器.
但是,如果没有用户名,我的索引页将执行重定向到登录.所以我做了以下调用:http://:8080/app,但重定向转到http:/// session/new而不是http:/// app/sessio/new我不是很确定apache配置不当,我更担心rails 3.
下面是我的apache配置这个代理的东西,我的routes.rb文件和我发现的潜在的反向代理修复的一些代码,但它似乎不起作用.
REVERSE_PROXY_FIX
BASE_URL = ''
module ActionController
  ActionController::Base.asset_host= BASE_URL
  class UrlRewriter
#    alias old_rewrite_url rewrite_url
    # Prepends the BASE_URL to all of the URL requests created by the
    # URL rewriter in Rails.
    def rewrite_url(path, options)
      url = old_rewrite_url(path, options)
      url = url.gsub(@request.protocol + @request.host_with_port, '')
      url = BASE_URL + url
      url
    end
  end
end 
Run Code Online (Sandbox Code Playgroud)
Apache2配置
# This file contains the proxy settings for apache to map all the incomming …Run Code Online (Sandbox Code Playgroud) 我正在尝试将一些AppSettings加载到一个对象中.设置如下所示:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="Logging_default_path" value="C:\Temp" />
    <add key="Logging_max_file_size" value="10485760" />
    <add key="Logging_levels" value="Error,Warning,Info"/>
    <add key="Logging_filename" value="RobinsonLog" />
  </appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
该Logging_levels 表示由设置允许几个枚举值.我正在尝试使用以下代码将这些加载到我的对象中:
Level = (LogLevel)Enum.Parse(typeof(LogLevel), settings["Logging_levels"]);
Run Code Online (Sandbox Code Playgroud)
但这不起作用,我只返回LogLevel.Info,而不是Loglevel.Error |的值 LogLevel.Warning | LogLevel.Info.枚举定义如下:
[Flags]
public enum LogLevel
{
    Error = 0x0,
    Warning = 0x1,
    Info = 0x2,
    Debug = 0x3,
    Performance = 0x4
}
Run Code Online (Sandbox Code Playgroud)
通过以十六进制定义值,我错了吗?还是我错过了别的什么?
一直在玩Capistrano以在我的服务器和我的开发机器之间进行自动部署.我几乎已经配置了,除了Capistrano似乎无法使用bundle exec命令启动我的服务器.我总是收到以下错误:
编辑:配置文件现在位于/var/www/apps/current/thin.yml
...
  * executing "sudo -p 'sudo password: ' bundle exec thin start -C /var/www/thin.config.yml"
    servers: ["85.255.206.157"]
    [85.255.206.157] executing command
 ** [out :: 85.255.206.157] Could not locate Gemfile
    command finished in 216ms
failed: "sh -c 'sudo -p '\\''sudo password: '\\'' bundle exec thin start -C /var/www/thin.config.yml'" on 85.255.206.157
仅复制了相关的最后一部分.整个文件等的复制工作正常.它只是启动似乎失败的集群.这是我的deploy.rb文件,它处理所有Capistrano的东西:
编辑:该文件已被修改为以下内容:
require "bundler/capistrano"
# define the application and Version Control settings
set :application, "ESCO Matching Demo"
set :repository,  "svn://192.168.33.70/RubyOnRails/ESCO"
set :deploy_via, :copy
# Set the login credentials for Capistrano …Run Code Online (Sandbox Code Playgroud) c# ×5
.net ×3
odata ×3
ruby ×3
rubygems ×2
wcf ×2
apache2 ×1
asp.net ×1
bundler ×1
capistrano ×1
dataservice ×1
datetime ×1
deployment ×1
enums ×1
irb ×1
md5 ×1
msbuild ×1
mysql ×1
mysql2 ×1
nhibernate ×1
ntlm ×1
parsing ×1
ruby-1.9.3 ×1
thin ×1
windows ×1