12/12/2018

lftp download and delete the files

最近與一個客人做 EDI, 他們的系統只能透過 FTP 來下載 Status. 但是我們的 File 每次都是幾萬筆上去, 所以產上的 Status File 就有幾十萬筆, 根本是不實際的做法.

因為現在累積的檔案太多要 Download, 我得找個辦法從 FTP server 下載下來, 然後 remove the file form the source.

原先用 WinSCP, 他提供 get -delete 的方式, 可以下載完 File, 然後 Delete 掉 Source. 但真的不是很快, 我得再找個更快的方法.

後來看到有人用 lftp mirror 的方式, 看起來簡單好用. 我已經在外面的 hosting 上測試過, 快多了. 但是現在要在我公司的電腦上, run lftp under Cygwin, 不知道效果如何?

指令參考 : https://stackoverflow.com/questions/16502034/download-and-delete-remote-files-using-lftp

lftp sftp://${username}@${host} -u ${username},${password} -e "mirror --Remove-source-files --verbose ${remote_dir} ${local_dir}; bye"

Update: 12/12/2018
在 Windows Cygwin 下, 連到 Server 之後, 抓了 Directory, File Count, 就跳出來了. 一_一|||

11/20/2018

NopCommerce 4.1 - EF Migration


  1. Install the Package Manager Console tools by running the following command in Package Manager Console:
    Install-Package Microsoft.EntityFrameworkCore.Tools
    Reference: .Net Core EF Migration - https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/
  2. Add connection string into appsettings.json
    "ConnectionStrings": { "nopCommerce": "Data Source=.;Initial Catalog=nopdb;Integrated Security=False;Persist Security Info=False;User ID=nopuser;Password=xxxxxxxxxx;" }
  3. Modify NopObjectContext.cs
    public NopObjectContext() :
        this(new DbContextOptionsBuilder().UseSqlServer(new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").Build().GetConnectionString("nopCommerce")).Options)
    {

    }
  4. Add-Migration InitialMigrations
  5. Remove all create/drop table code, just leave the Up and Down methods empty.
  6. Update-Database