小编tbl*_*tbl的帖子

如何强制Robocopy覆盖文件?

通常,Robocopy会忽略lastwrittendate和filesize相同的文件.我们怎样才能摆脱这种设计?我想用Robocopy强制覆盖.

我希望dst\sample.txt应该写成test001.但是这些文件被Robocopy识别为相同的文件而不会被覆盖.在这种情况下,"/ IS"选项无效.

New-Item src -itemType Directory
New-Item dst -itemType Directory
New-Item src\sample.txt -itemType File -Value "test001"
New-Item dst\sample.txt -itemType File -Value "test002"
Set-ItemProperty src\sample.txt -Name LastWriteTime -Value "2016/1/1 15:00:00"
Set-ItemProperty dst\sample.txt -Name LastWriteTime -Value "2016/1/1 15:00:00"

ROBOCOPY.exe src dst /COPYALL /MIR
Get-Content src\sample.txt, dst\sample.txt
> test001
> test002

ROBOCOPY.exe src dst /COPYALL /MIR /IS
Get-Content src\sample.txt, dst\sample.txt
> test001
> test002
Run Code Online (Sandbox Code Playgroud)

windows powershell ntfs robocopy

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

如何使用Devise停止软删除用户的登录

我目前在Rails项目中使用Devise进行用户注册/身份验证.当用户想要取消其帐户时,将以如下方式软删除用户对象.

如何用Devise"软删除"用户

我的这种方式有很小的不同.用户模型具有属性'deleted_flag'.并且,soft_delete方法执行"update_attribtue(:deleted_flag,true)"

但是,我必须实施sign_in行动.在我的implmenetation是以下.

class SessionsController < Devise::SessionsController
  def create
    resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#new")    

    if resource.deleted_flag
      p "deleted account : " + resource.deleted_flag.to_s
      sign_out(resource)
      render :controller => :users, :action => :index
    else
      if is_navigational_format?
        if resource.sign_in_count == 1
          set_flash_message(:notice, :signed_in_first_time)
        else
          set_flash_message(:notice, :signed_in)
        end
      end
      sign_in(resource_name, resource)
      respond_with resource, :location => redirect_location(resource_name, resource)
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

我认为这段代码有点奇怪.

如果删除的用户试图进入,系统会允许记录并立即注销.并且,系统无法显示flash [:alert]消息...

我想知道两点.

  1. 如何实施禁止已删除的用户登录?
  2. 当被删除的用户尝试登录时,如何实现显示flash [:alert]?

login ruby-on-rails devise

6
推荐指数
2
解决办法
3299
查看次数

如何在另一个活动中调用方法

我对Android实施程序活动之间的沟通有疑问.

这是两个活动类.

public class HelloAndroidActivity extends TabActivity{
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Resources res = getResources();
        TabHost tabHost = getTabHost();
        TabHost.TabSpec spec;
        Intent intent;

        intent = new Intent().setClass(this, Tab1Activity.class);
        spec = tabHost.newTabSpec("Tab1").setIndicator(
          "Tab1", res.getDrawable(R.drawable.ic_tab_icon))
          .setContent(intent);
        tabHost.addTab(spec);
    }
}
Run Code Online (Sandbox Code Playgroud)

_

public class Tab1Activity extends ListActivity {
    private ArrayList<String> list = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);  

        list = new ArrayList<String>();
        setListAdapter(new ArrayAdapter<String>(this,  
                android.R.layout.simple_list_item_1, list)); 

        addColumn("one");
        addColumn("two");
        addColumn("three");
    }

    public void addColumn(String s){
        list.add(new String(s));
    }
} …
Run Code Online (Sandbox Code Playgroud)

tabs android message android-intent android-activity

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

如何在编写jUnit for web servlet时管理log4j.properties

我正在开发web servlet并且与log4j.properities混淆了,我定义了在构造函数中调用initialize logger.

public static Logger logger = Logger.getLogger(MyProject.class.getName());
public MyProject() {
    super();
    // TODO Auto-generated constructor stub
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    URL url = loader.getResource("log4j.properties");
    PropertyConfigurator.configure(url);
}
Run Code Online (Sandbox Code Playgroud)

通常,关于web servlet的日志文件是指tomcat的日志目录.

log4j.rootLogger=debug, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=${catalina.base}/logs/myproject.log
log4j.appender.R.MaxFileSize=100KB
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
Run Code Online (Sandbox Code Playgroud)

但是,在为webservlet编写jUnit时,日志文件指的是不正确的地址,因为$ {catalina.base}是空白文本.错误日志在这里.

[junit] log4j:ERROR setFile(null,true) call failed.
[junit] java.io.FileNotFoundException: /logs/myproject.log (No such file or directory)
Run Code Online (Sandbox Code Playgroud)

所以,请教我明智的管理日志文件.我希望在通过jUnit测试时停止输出日志文件.

junit tomcat log4j

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